10 November 2011

Hide WordPress Admin Link

If you're editing or building a WordPress theme, and want to hide the 'Admin' link, the solution is very simple:

<?php if (current_user_can("manage_options")) : ?>
       <a href="<?php echo bloginfo("siteurl") ?>/wp-admin/">Admin</a>
<?php endif; ?>
This will show a link saying 'Admin' if an admin is logged in, for all other users and logged-out users nothing is displayed.

1 comment:

  1. Should add- this works at version 3.2.x and is likely to for all of the 2.x & 3.x branches- but may not in the future.

    And if you're still using 2.x - please upgrade now!