WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Morning all, I'm having a bit of trouble finding a function I can use to link to a post type from the admin area. I'm actually using something as simple as:

<a href='edit.php?post_type=slides'>Slides</a>

in another area, but didn't know if there was a better way of handling it (since I'm still technically hardcoding in the first part of the URL). The post type name being hardcoded isn't the issue, really just generating that first part of the URL. Thanks!

share|improve this question
up vote 1 down vote accepted

The following should do the trick:

  <a href=" <?php admin_url('edit.php?post_type=slides') ?>">Slides</a>

It's how it's done in the source code. The function admin_url() appends the proper admin address. The output of the url should be:

share|improve this answer
Awesome! One last part - if I am displaying this type of link within an array, do you know how I'd properly encode that to not escape the array value? "desc" => "Enable either a static main image or a dynamic slideshow populated by the <a href='admin_url(edit.php?post_type=slides)'>Slides</a> content type", Banging my head against the wall with this part. Thanks! – Zach Nov 30 '11 at 15:24
Ah - figured this one out by myself - if it's useful to anyone else - I just set the content type link as a variable and then spit that out in the array statement: $slides_link = '<a href="'.admin_url("edit.php?post_type=slides").'">Slides</a>'; "desc" => "Enable either a static main image or a dynamic slideshow populated by the $slides_link content type", Thanks again for the help! – Zach Nov 30 '11 at 15:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.