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
- Redeclare/Change Slug of a Plugin’s Custom Post Type
- How to remove custom post type archive
- How to use a custom post type archive as front page?
- Custom Post Type Archives by Year & Month?
- Theme localization of “slugs” (custom post types, taxonomies)
- Get custom post type slug for an archive page
- Create a custom archive page for a custom post type in a plugin
- Custom Post Type Slug / Page Slug Conflict – Prevent use of reserved slug on page save?
- Custom Post Type Settings page, choose page to display archive
- Adding a menu item for a Custom Post Archive
- Custom Post Type Archive Page not showing
- Adding custom post type archives to a WordPress menu
- How to set a custom post type to have viewable future posts
- Custom Post Type Template – Archive
- How do I get a post (page or CPT) ID from a title or slug?
- Page Template as Custom Post Type Archive
- How to get custom post type label and singular label from its slug?
- Custom Post type & Taxonomy URL structure
- custom slug for custom post type
- Custom post type yearly/ monthly archive permalinks
- Slug Formatting : Acceptable Characters?
- Disable permalink on custom post type
- Get list of all registered post types slugs
- Combining Multiple Taxonomies in one URL
- Can’t get post id on page that is a custom post type archive
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- How do you create an archive for a custom post type from a plugin?
- Using Custom Fields in Custom Post Type URL
- Proper way of making custom post type landing page or archive page
- Custom Post Type Archives by Date with Custom Permalink
- Change slug of registered custom post type in child theme
- How to List All Custom Post Types Names (Not Posts)
- Change title in head on Archive page
- Taxonomy archive with same slug as custom post type?
- Custom Post Type Archives with 0 Posts Redirects as 404
- Dynamic taxonomy in permalink made all other posts NOT FOUND?
- How to filter custom post type archive by meta value
- What are the advantages of using a custom post type archive?
- Page is defaulting to archive page and not designated template
- custom post type archive page url to point to Page permalink
- Post slug changed using code doesn’t reflect on editor when post is published
- “Edit” option for custom post types archive page
- How to achieve this permalink -> category-name/custom-post-type-name/post-name
- Custom Post Type archive as front page
- Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?
- Get monthly archives for custom post type
- Is it possible to remove the posts_per_page limit on a specific post type?
- Taxonomy page returns 404 page not found
- Add Settings to Custom Post Type
- Is it possible to have an index page for taxonomy term for each custom post type it is assigned to?
- Custom post type permalink structure with the category also acting as an archive
- How to get_queried_object on multiple objects?
- Prepend meta_value to permalink of post
- Custom Post Type Works but Still Shows “Page Not Found”
- Custom Post Type – Same Post Name, Different Post Type
- Assign Page Template Within A Custom Post Type
- Custom Post Type / Taxonomy Slug / Post Title with post type archive
- Rewrite custom post type url’s adding meta box values
- I can’t set meta_key in my custom post type query
- Hide child term posts on parent term pages
- Posts per Page on custom Taxonomy Template
- Compare 3 custom fields and sort by oldest
- Post type archive page not working
- Priority for Categories, Tags, Taxonomies, Posts, Pages and Custom Posts with same url
- Adding Sticky functionality to Custom Post Type Archives
- Setting a title on a Custom Post Type that doesn’t support titles
- Reslug a Custom Post Type
- Removing CPT slug from URL results in 404 error for archive page
- Custom Post Type pagination when CPT ‘rewrite’ rule and a page have the same slug
- Remove Slug from Custom Post Type results in 404
- Force unique page slugs across all post types
- Getting Post ID from slug during init
- paginate function in archive for custom-post-type
- Adding custom post types to archive.php
- Custom Post Type – Archive page title
- Alphabetical sorting of custom post type – one letter per page
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- Custom Slug for a custom post type and default post
- Archive page for taxonomy of custom post type
- Add meta data to the custom post type ARCHIVES page
- Should I change these content meta types before building complex archive page?
- Remove taxonomy slug when not assigning taxonomy with custom post types
- Custom post type’s slug gets wrong when adding a custom meta box
- archive-{$post_type}.php not loading. instead the default archive.php loads
- Interesting Custom Post Type Slug with Taxonomy and Custom Field
- Getting taxonomy terms used by custom post type
- Custom post type archive sorted and grouped by date in post meta field
- Rewrite CPT slug with two taxonomy slug instead of one
- Archive or taxonomy pages not working for custom post type
- Get slug to point to different content of the same post
- Create Custom Post Type Archive Page with Sub Categories Navigation Sidebar
- Custom Post Type archive giving 404
- WP query by custom post type slug/name
- How to create archive page for taxonomy terms within custom post type
- How to make an archive page displaying posts in a date range
- Can’t edit Custom Post Type slug/permalink