Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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:

http://www.mysite.com/wp-admin/edit.php?post_type=slides 
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
add comment

Your Answer

 
discard

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.