get_post_type_archive_link()
Retrieves the permalink for a post type archive.
Uses: get_post_type_object()
Hooks from the function
Return
String|false
. The post type archive permalink. False if the post type does not exist or does not have an archive.
Usage
get_post_type_archive_link( $post_type );
- $post_type(string) (required)
- Post type.
Examples
#1 Link to the archive page of the custom post type
Let's say we created a post type book
with register_post_type(). Let's display a link to an archive page of this type (page with all posts of this type):
<a href="<?php echo get_post_type_archive_link('book'); ?>">Books</a>
Notes
- Global. WP_Rewrite. $wp_rewrite WordPress rewrite component.
Changelog
Since 3.1.0 | Introduced. |
Since 4.5.0 | Support for posts was added. |