Reputation: 131
I'm writing a sidebar for my site and I'm trying to check if:
is_post()
current_user_can('edit_post')
I'm trying to combine both of these conditions, but I'm horrid at PHP and I just can't figure out the syntax to do so. I figured it'd be something like below. Could you please let me know what I'm doing wrong? I'm assuming it's something simple, but my inexperience is causing problems and I can't find the right example/documentation to help me out.
<?php if is_single and if (current_user_can('edit_post')) { ?> <li><a href="#">Edit post</a></li> <?php ;} ?>
Upvotes: 1
Views: 2671
Reputation: 17295
The syntax and idea is:
if (true && true) {
// things will happen ...
}
For your functions:
if (is_single() && current_user_can('edit_post')) { ...
Upvotes: 2
Reputation: 382826
It should be:
<?php if (is_single() && current_user_can('edit_post')) { ?>
<li><a href="#">Edit post</a></li>
<?php } ?>
Upvotes: 8