You can filter template_include
and pass your custom template as return value depending on your own conditions.
Sample code, not tested:
add_filter( 'template_include', function( $template )
{
// your custom post types
$my_types = array( 'photography', 'painting' );
$post_type = get_post_type();
if ( ! in_array( $post_type, $my_types ) )
return $template;
return get_stylesheet_directory() . '/single-photography.php';
});
Related Posts:
- How to set a fall back template for a custom post type in a plugin?
- Custom Post Type Archive URL takes over page URL
- Template tags to display custom post type posts in category template?
- How to specify a template for a path like http://example.com/something?
- Assign a template to a custom post type when displayed by the main loop on the home page
- Post template not applying on theme (potentially rendering as Page template)
- Custom Post Taxonomy Template Not Loading Properly
- Custom post type single page uses the right template in preview mode but shows a different template after being posted
- Values show up in custom home page but not in custom post pages
- Having some trouble properly displaying Custom Post Types in templates
- How to create custom page templates with default page layout framework?
- How to check if a custom post type uses a custom template?
- Custom PHP Template in Twenty Twenty-Four
- Create template for taxonomy results limited by Custom Post Type
- Template for custom post with custom taxonomy
- WordPress Custom Post Type Children Template
- Allow non-logged in users to see a future post after clicking on a list of future posts
- Help need making decision. Ads rotating site on wordpress
- Getting template_include to work when allow_url_include is off?
- Query & Order posts by custom fields
- Custom post type content using custom fields without template
- custom taxonamy and post type
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- 2 Templates 1 custom post type according url
- Return the latest post from a custom Taxonomy and Post Type
- Don’t know how to show custom taxonomies from a custom post_type
- Not Able to Get Custom Post Type Gallery Images URL
- Custom taxonomy and custom post type – wrong permalinks and template
- JS innerhtml changing style when using AJAX
- Can I override a CPT template on a per post basis with Gutenberg block editor?
- Display a grid of taxonomy terms at root taxonomy page
- How to Upload CSV Data into Custom Post Type Data with Metabox programmatically
- How to change the post type a theme shows by default?
- Get unique superset of taxonomy terms from a list of custom posts in another hierarchical taxonomy
- Content vs Template on custom post
- How to use custom template files in deeper directory?
- Event Custom Post Type Title show by upcoming Event Dates
- WordPress Doesn’t Generate Taxonomy Archive
- How to have this permalink structure: post_type/postname/custom_inner_page
- A case for Hierarchical Custom Posts
- Building a Treatments Page, What Do I Use?
- Custom taxonomy returns 404
- Filter widget outputs
- Adding Page Templates to post but it ignored it
- Template for all categories of a custom post type?
- Custom post types and category archive
- Migrating a taxonomy’s tags to the native category
- Flush Rewrite Rules when new site is created on network
- custom comments form for custom post type
- How to produce a sub-page-system in WordPress
- WordPress custom taxonomy template not working
- How can I get this request to use the Custom Post Type page template instead?
- WebP Fallback for Inline Background Image in Style Attribute
- Custom templates for a specific category
- Archive for a Taxonomy of a Custom Post type
- Warning: Invalid argument supplied for foreach() [closed]
- Custom post type isn’t working
- Custom post type pages return 404 page?
- Warning: Invalid argument supplied for foreach() in post.php [closed]
- WordPress 3.9 not using custom template
- Template files for Custom Post Type and Taxonomy
- Set templates for custom post types
- How to Create Template File for Parent Page of Custom Post Type
- Custom post_type search pages
- How can i link a custom post type thumbnail to intermediate size
- i cant see the max_num_pages of a custom wp query
- how to remove pages loading with the archive templates
- Archieve.php not loading for custom post type
- Getting Un Wanted Gallery Shortcode In The Page on Loop
- Main query not querying any posts in custom taxonomy template
- Custom Empty Results page for my Custom Post Type
- detect your custom post type in WordPress
- Custom posts template page
- Display custom post using ID
- Loop through custom posts by taxonomy and display the titles in a list, it is repeating 8 times
- Custom WP_Query doesn’t display all posts
- How can I use archive-{post_type}.php theme template?
- Specify a particular page to list all custom types
- WordPress app page not found error for posts with hyphen in permalink
- Where is the sticky post option?
- make permalink go to a custom single.php file
- Two column layout with alphabetical ordering
- Add Previous/Next Buttons to CPT Single Pages Only
- Creating Sections for Post Types
- Create a comments template for custom post types
- Custom post type permalink sends to 404.php
- Custom post types with categories in template
- WP_Query with custom post type ID
- Creating separate feeds for custom post types
- Which file/template is in charge of taxonomies for custom post types?
- Api rest_route 404 while building filter for custom posts (filtered by multiple meta keys / custom fields)
- how to get this tax_query working?
- How can I trace inconsistency in loading a template?
- Show Taxonomies with admin area for custom post type?
- How to get_term_meta on single custom post?
- Pagination doesnt work in custom post type
- Archive links for custom post types
- Include custom post type custom taxonomies in Categories widget
- Template Hierarchy for custom post type pages
- Should Custom post types and fields be in the theme files or in a custom plugin packed into the theme?