I can get the permalink of a specific post tag or category, but what if I want to get the permalink of a custom post type? I can’t find anything in the Codex or anywhere else about how to do this.
Leave a Reply
You must be logged in to post a comment.
How about
href="<?php echo get_post_type_archive_link( $post_type ); ?>"
, where$post_type
is your post type?Further reading: Codex
Within the loop, you can simply use
the_permalink()
. Outside of the loop, you can useget_permalink( $id )
.Or, for what it’s worth,
get_term_link($term, $taxonomy);
– Codex.I know this post might be old but just in case someone else is searching the function that does this, here’s the one i wrote. $post_type must be passed as a variable 🙂
Hope it helps ! 🙂