Function to get permalink of custom post type archives?

Is there a function that will return the permalink to a custom post types archives that is available to use in WordPress?

Something like:

get_cpt_permalink("events") which will return http://example.com/events/ when has_archive => true on it.

If not what would I need to home brew my own? I’m thinking I would need to read $wp_rewrite and use something along the lines of $wp_rewrite->get_extra_permastruct('events');

1 Answer
1

This is what you are looking for get_post_type_archive_link( $post_type );

Leave a Comment