0

How can I retrieve the slug for a particular custom post type via its name? I would appreciate some assistance.

3
  • Aren't these functions wp_get_post_terms & get_term_by any use for you? – sri Nov 26 '13 at 16:56
  • @sri Those functions seem to be related to individual posts and taxonomies. I don't see how I can use them for my purposes. – Richard Nov 26 '13 at 16:59
  • 1
    Have you tried anything at all? Then please share your code... – sri Nov 26 '13 at 17:09
0

I found an alternative solution: get_post_type_archive_link( $post_type );

Instead of providing a slug, it retrieves the archive url for a designated custom post type.

e.g.

<a href="<?php echo get_post_type_archive_link( 'books' ); ?>">Movies Archive</a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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