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="https://wordpress.stackexchange.com/questions/124559/<?php echo get_post_type_archive_link("books' ); ?>">Movies Archive</a>
Related Posts:
- CPT custom archive template does not get loaded
- Custom post type post_type_link gives “page not found” on any other custom post type
- Rewriting archive page slug to be different than custom post type slug
- Remove slug from custom post type post URLs
- Create a custom archive page for a custom post type in a plugin
- Custom Post Type Archive Page not showing
- How to get custom post type label and singular label from its slug?
- Change slug of registered custom post type in child theme
- Page is defaulting to archive page and not designated template
- custom post type archive page url to point to Page permalink
- How to achieve this permalink -> category-name/custom-post-type-name/post-name
- Add Settings to Custom Post Type
- Custom post type permalink structure with the category also acting as an archive
- Prepend meta_value to permalink of post
- Custom Post Type Works but Still Shows “Page Not Found”
- Rewrite custom post type url’s adding meta box values
- I can’t set meta_key in my custom post type query
- Archive page for taxonomy of custom post type
- Remove taxonomy slug when not assigning taxonomy with custom post types
- Create Custom Post Type Archive Page with Sub Categories Navigation Sidebar
- Custom taxonomy template not working with simple loop. Multiple CPT using the same taxonomy
- Custom query variable – get wordpress to redirect to nice permalink url
- Add custom post type archives to search results?
- Second Custom Post Type Archive
- How do I get the permalink structure to work like this?
- is_main_query() not working for WP REST API
- WP_Query | ‘post_type’ doesn’t work
- Editable Meta Data for Custom Post Type Archive Template
- Archives for Custom Post Types (without Pages)
- Why does wordpress keep adding postname to my CPT’s permalink in the end?
- Set up Custom-Post-Type Author Archive
- Rewrite slug for CPT
- Custom post type templating problem
- Is there a way to have custom post type and page with the same slug?
- Using Same Slug With Multiple Post Types
- Adding Post id to the end of slug in a Custom Post Type
- Remove the parent slug in a CPT URL
- Index page with the same id as the slug
- Single post with a Custom Post Type returns 404, when archives of the CPT work correctly
- Custom post type archive page blank
- Creating a Custom Post Type
- Custom Post Type slug same as page name
- Removed custom post type slug but not working for child pages
- Custom Post Type – Duplicate Page Slugs
- Remove permalink for custom post type
- Rename a slug label
- How to set up Custom Post Type archive page as Front page
- Using page slug in wp_query
- Listing all slugs?
- Custom Permalinks For CPT and pages with parent. Advanced WordPress
- How to integrate single and archive templates for custom post type in any WordPress theme
- ACF for custom post type archive pages: which hook to use?
- Automatically update slug with latest title within custom post type [duplicate]
- Show categories of custom post type and not all posts
- Removed custom post type archive page shows blog page
- How to use a specific custom field in a custom post type as slug
- Plain links in single-class.php and archive-class.php not working
- sort by name (slug) custom post type
- Archive page for custom post type and custom taxonomy
- Pagination does not work on Custom Post Type archive while trying to get load more function working
- Create a Custom Path to Archive
- Specifying a template for custom post type pages
- How to change CPT single post slug
- How to set a ‘page’ as parent of a custom post type?
- Archive page for WordPress Custom Post Type doesn’t show pagination from paginate_links()
- 2 Custom Post Types In 1 Archive Page?
- Custom Post type dont use custom page template (slug is not right)
- Custom post type archive URLs with a single taxonomy
- Different number posts per page based on custom post type term id
- How to change URL for custom post type archive?
- Custom post type author issues
- Difference between a default post type and a custom post type?
- Do not show child pages within a file page
- Custom Post Type not using correct page template
- Custom post type URL structure with site.com/custom_taxonomy_slug/post_name
- Custom taxonomy archive slug overwrites static page
- Slugs on hierarchical taxonomies
- Custome post type “tags” pick default archive instead of custom post type archive
- Highlight a Post on archive page if it has a new comment?
- How do I make my archive page look like popular reviewing sites (e.g., Polygon and Gamespot) [closed]
- Get full control over custom post type url
- Remove the “View” Link in Post edit Admin
- Custom Post Type Archive Links Not Working
- CPT archive as home page
- Add category slug as class attribute in a link array
- Relationship with 2 custom post types
- Category slug not showing for Custom Post Type
- How to display the FAQ Archive page in my menu
- Why is this custom post type defaulting to archive.php?
- Archive Page Pagination not working
- Custom Post Type Slug / Page Slug Conflict – Prevent use of reserved slug on page save?
- single-mySlug.php works: archive-mySlug.php does not. Custom Post Type
- has_archive for default post type
- is this a bug or not?
- Pagination for Custom Post Type with Multiple Types
- Custom Post Type Archive Title Lowercase
- Pagination not working only on Archive-Name.php using new WP_Query
- Hide custom post type slug url from search engine [closed]
- Custom post type Premalinks main page and details page
- Can’t add custom post type archive page to menu