Small hack for a quick Admin link in WordPress

I’ve been playing with WordPress a lot lately and I’m really starting to feel the Love ! I’m still customizing our this blog and needed to have a quick Admin link easily accessible to go in the admin panel of WordPress. Yes, I can always scroll down the right column and click on Site Admin link in the Meta block. But, I have to scroll, and I hate that ;-) . So I decided to hack in in. And I thought I’d share this. Oh and I’m sure thousand of people have done this already, but hey, the more the merrier, right ?

So I went in Admin > Appearance > Editor to edit the header.php file of the theme I’m using. I located the place where I wanted to insert the link and used theis_user_logged_in function to test if we wanted to display the admin link or not. Then, I used the admin_url function (which is not documented in WordPress codex ?) to get the URL we needed to access the admin side. So, all in all, it looks like this:

<?php if (is_user_logged_in()) {?> | <a href=”<?=admin_url();?>”>Admin</a><? } ?>

Here is a screenshot of what it looks like when loged in:

adminLink

  • Twitter
  • Facebook

About Marc-André Lanciault

Entrepreneur at heart, evangelist of all that the Web has to offer, Marc-André is founder and CEO of INBOX International, a Montreal based agency specializing in Web development and marketing.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>