I'm looking to add a link to my blog nav where only I, the Admin, can view the link when logged in, just like the Site Admin link that shows up when I'm logged in. I can't find anything online that mentions how to do this. Anyone knows?
I'm looking to add a link to my blog nav where only I, the Admin, can view the link when logged in, just like the Site Admin link that shows up when I'm logged in. I can't find anything online that mentions how to do this. Anyone knows?
You can use either:
if ( current_user_can('edit_post') )
or
if ( $user_ID )
There are some differences, so check them out first.
Thanks but I'm not sure what the differences are or how to implement the code. Could you give me more details?
Try
<?php if ( $user_ID ) { ?>
<a>...</a>
<php } ?>
The link will show for any logged in user.
Thanks. Now how do I make it so it's only visible to the admin instead of every logged in user?
I'm getting the following error when I drop in that code:
Parse error: syntax error, unexpected $end in /home/16094/domains/aisleone.net/html/wp-content/themes/default/sidebar.php on line 119
Then try this:
if ( current_user_can('edit_posts') ) { ?>
<a>...</a>
<php }
Look for the <?php ... ?> tags. You can paste this somewhere between them, or use them at the beginning and the end.
I dunno dude it's not working. Im still getting that parse error. Thanks for the help though. I appreciate it.
Where about in sidebar.php are you trying to put this? You can paste it including <?php ... ?> just before the last </div>, line 67.
I'm putting it in here:
<?php wp_register(); ?>
RIGHT HERE
<?php wp_loginout(); ?>
It should work there... Did you surround it with <?php ... ?> like that:
<?php if ( current_user_can('edit_posts') ) { ?>
<a>...</a>
<?php } ?>That worked man thanks! I probably typed it in wrong.
Thanks again.
This topic has been closed to new replies.