• 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?

Viewing 11 replies - 1 through 11 (of 11 total)
  • You can use either:
    if ( current_user_can('edit_post') )
    or
    if ( $user_ID )
    There are some differences, so check them out first.

    Thread Starter yots

    (@yots)

    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.

    Thread Starter yots

    (@yots)

    Thanks. Now how do I make it so it’s only visible to the admin instead of every logged in user?

    Thread Starter yots

    (@yots)

    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.

    Thread Starter yots

    (@yots)

    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.

    Thread Starter yots

    (@yots)

    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 } ?>

    Thread Starter yots

    (@yots)

    That worked man thanks! I probably typed it in wrong.

    Thanks again.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Adding Admin only nav links.’ is closed to new replies.