add_filter( 'template_include', 'wpsites_cpt_archive_page_template', 99 );
function wpsites_cpt_archive_page_template( $template ) {
if ( is_post_type_archive() ) {
$new_template = locate_template( array( 'your-cpt-template.php' ) );
if ( '' != $new_template ) {
return $new_template ;
}
}
return $template;
}
Try this in your functions file.
You can add your post types to this line like this:
if ( is_post_type_archive(array( first-post-type, second-post-type ) ) ) {
Related Posts:
- Overriding the template files using a plugin for all themes
- What is the link to my default “archive” page?
- Loading partial templates with AJAX/PJAX
- Page is defaulting to archive page and not designated template
- Templates & CSS – Proper Programming Practice?
- Post formats template
- index.php template is used instead of blog page
- Same template for all the terms of a taxonomy
- Load template file without a post type
- How to apply a custom template for posts by default?
- Unable to include a template
- What should I put on my index.php?
- When a link doesn’t exist, how to tell WordPress what to do? (404 Error Page)
- Is there a way to set different post templates for parent posts and child posts in the same post type?
- Create template for taxonomy results limited by Custom Post Type
- Get link to a specific template file [closed]
- Having trouble with Template hierarchy. I Need to create a set of pages that drill down from states to specific locations
- Custom templates vs page-slug
- How can I force URL of a custom post type archive to use a page template?
- Understanding the Template hierarchy
- How does WordPress choose archive type template?
- What is the best practice to style archive page 2,3,etc differently than archive.php?
- How to use index.php as a template for archives?
- get_month_link uses what wordpress template?
- How can I use archive-{post_type}.php theme template?
- Archive template limiting to 4 entries?
- Force WordPress to NOT display the manual excerpt
- Differentiation between index.php and page.php
- Single-page.php template file name not shown
- How can I get all archive-URLs to use the same template?
- Can I assign a Folder for Post Formats, without it affecting WordPress’ fallback/hierarchical system?
- How to display custom post type?
- Assigning custom page templates to a static blog page
- Archive-custome_post.php template not working
- Overwriting TwentyTwelve template file with child theme template, but lower in the hierarchy
- Organize template parts and page templates in folders in regards of template hierarchy
- Help Understanding Template Hierarchy
- Is it possible to set archive.php instead of index.php to display blog?
- User role templates
- Assign template to custom page type?
- BuddyPress : how can I call the template WordPress would have chosen (template hierarchy)?
- How can I make custom page templates work on child theme?
- Archive only for /year/month, not terms
- URL Rewrite and Archive Template Files – Post Type vs. Taxonomy
- Which template(s) to override to use a different sidebar for blog, single posts, categories, blog archive?
- Single Post Templates Doubt
- Is it possible to return a specific tag archive/template as one of the search results?
- Page Templates Used in Custom Post Type
- Show a custom template, no matter the page being viewed, if the user is not logged in
- Custom post type category page not working
- Custom Archive with Content for Custom Post Type
- Tag Posts showing in wrong places
- Problem with permalink structure for WordPress custom post_type archive template
- Unload templates; disable parent Template Parts using only “theme.json”
- How can i change email template for new user
- Enable page templates. How?
- Is it possible to override the result of get_template_part()?
- Custom templates folder
- get page templates
- How to assign a class to a page with a custom template?
- How to Handle CSS for Multiple Header header.php Files?
- page_template toggle between 2 templates + 2 permalinks for same post
- Output yearly archive within a page
- Proper Javascript Implementation
- Guest author’s post not display in author template
- Custom-post-type-archive: posts sorted/filtered by year?
- How to remove wp_link_pages() from template
- How can I get WP to use templates in lower-level subfolder?
- Generate Catalog Of Posts Based On Template
- Extending body classes in front- and backend
- Why write markup for index.php?
- How to identify which template WordPress’s default search-form retrieves in my theme
- Is there any way to write custom HTML is some .php file and then call it wherever necessary?
- How to redirect my custom template page to content-none.php if no posts found?
- Automatically use specific template to load subpages
- Can’t split the_title() by white space
- Not so common HTML transition to wordpress issue
- How to create new template page and template-parts in wordpress theme [closed]
- Pagination issue with tag.php
- How are the HTML classes generated?
- Archive Template being used instead of Category Template for Custom Post Type
- Blog page won’t show Blog template
- How can I allow users to edit text that will be displayed on a custom post type archive page?
- How can I abstract code out of a template by using functions.php
- how to change already posted blog to custom template wordpress?
- Is possible register two archive pages for single custom post type?
- WordPress change title with custom dynamic
- template with multiple post loops for multiple widgets [duplicate]
- Random home page at each refresh between array of page IDs
- Do not trigger page 404 on custom template
- Change Page Template Based on URL Rewrite in WordPress
- Custom Post Type Archive – archive.php is present, but it is not being used
- Stop Custom post type from being searched via URL
- printf, translation and the_author_posts_link()
- Custom Archive Page
- Pagination not working for archive
- front page won’t change templates
- Including 2 Negative Is_Template Conditionals in header.php [closed]
- Add custom card template to masonry layout using Essential Grid [closed]
- Where is the general html template file?