Monday, July 8, 2013

How to display admin panel link only for admins in wordpress

Code below will let all logged admin users of the site (not just an subscriber or author) to see a link that get them to the WordPress Admin area. Otherwise, if not admin user will display nothing.

<?php if (current_user_can("manage_options")) : ?>
<a href="<?php echo bloginfo("siteurl") ?>/wp-admin/">Admin</a>
<?php endif; ?>

More specific than the regular log in / log out function, which will show for everyone:
<?php wp_loginout(); ?>

Disqus Comments