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 to use Class
in Java? - Get name of the current template file
- How do you find out which template page is serving the current page?
- How to change the default registration email ? (plugin and/or non-plugin)
- How do I get the size of an attachment file?
- Is there any way to use get_template_part() with folders?
- single-{$post_type}-{slug}.php for custom post types
- Custom Post Type Archives by Year & Month?
- Get custom post type slug for an archive page
- Adding Page Attributes Metabox and Page Templates to the Posts Edit Page?
- How can i change email template for new user
- Any advantage to using get_header() over include(‘header.php’)?
- Enable page templates. How?
- Is it possible to override the result of get_template_part()?
- Use [embed] filter in template files
- What’s the purpose of the paged.php file?
- How do you access the Product Short Description in a WooCommerce email template? [closed]
- Prevent comments_template() to load comments.php
- Is there a way to list all used/unused WP templates?
- Page editor missing Templates drop down
- Print WordPress template filename(s) for debugging
- How to force TinyMCE in WordPress to replace newlines with tags and not with
- How to find the posts page (home page) programatically
- WooCommerce: Change template for single product page
- View WordPress page template usage (or unused)
- How to edit contents of dynamic_sidebar()?
- How to check if a shortcode exists?
- Where is get_header(‘shop’) file in Woocommerce templates
- Custom templates folder
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- How to get slug of current category in taxonomy template?
- How to show a under construction page for a domain but still be able to work on index.php?
- Change the name of the ‘Default Template’
- Customizing get_the_excerpt() to specific length and “Read More” output.
- How to Rename a Template File?
- Template for specific post of custom post type
- get page templates
- Echoing Elementor page content in template, but it doesn’t get styles and some widgets are missing
- Using WordPress templating for HTML emails
- Is it possible to manipulate the list of page templates?
- Proper way of making custom post type landing page or archive page
- How do I display two separate taxonomy archives for two post types that share a single taxonomy?
- Custom Post Type Archives by Date with Custom Permalink
- WP frontend output of custom textarea fields not respecting line breaks. In admin it’s OK
- How do you check if a WordPress template file exist?
- Multiple Single Post templates