Filter template_include
, check if the current post is a product and load the product template.
Example:
add_filter( 'template_include', function( $template ) {
if ( ! is_singular() or ! get_post_meta( get_the_ID(), 'price', true ) )
return $template;
return locate_template( 'product-single.php' );
});
How exactly you determine if a post is a product is up to your implementation.
Related Posts:
- Disable Single Post View for Specific Taxonomy on Custom Post Type
- custom post type parsed as attachment
- How to make “single post” permalink maintain it’s sub-page structure
- Single page problem when permalink type changed
- Permalinks: custom post type -> custom taxonomy -> post
- Mixing custom post type and taxonomy rewrite structures?
- Resolve a custom post type name vs. page permalink conflict (same slug)
- How to rewrite URI of custom post type?
- How to change permalink structure for custom post type and it’s taxonomies?
- Conditional for single-{post-type}.php
- Change permalinks for posts but not for custom post types
- Custom post types – Use post_id in permalink structure
- Custom post type permalink: only use %post_id% and remove %postname%
- Permalink rewrite 404 conflict- WordPress Taxonomies/ CPT
- Rewrite custom post type rss feed links
- 404 on child page when parent page slug is identical to custom post type
- rewrite get parameter with custom post type
- Remove unwanted part of permalink custom structure from CPT url?
- Custom permalinks – post type – hierarchical taxonomy’s
- Using previous_post_link and next_post_link to wrap around post sequence
- Changing a custom post type “has_archive” after registered
- How do I create new content pages for my Custom Post Type?
- dynamically update permalink and title with the values of custom fileds
- Change permalink structure for custom post type
- Custom post types and permalinks : What a mess !
- Custom template for post type not working
- Custom Post Type slug same as page name causing a conflict
- Custom Post Type “Event” with custom permalink structure
- Custom Taxonomy breaking pages permalinks
- Permalinks without post type
- Custom post types and permalinks
- How to remove custom post type name from base url?
- Custom post type – how can I make it a sub-url of another page?
- Custom fields in Permalinks?
- Change URL of posts and also Custom Post Type
- Custom post template for particular posts
- Custom post type permalinks
- Use different taxonomies in different custom post types’ permalinks?
- post_type_link not working in gutenberg
- Custom template won’t load for a custom post type (custom permalinks used)
- Single Template that can be applied only via URL
- How can I update the permalink everywhere for a custom post type?
- How to hook custom taxonomies to custom post types and make the permalinks work?
- 404 Issue w/ Custom Post Type – using Meta for Permalink rewrite
- Help with Elementor Pagination CPT archive 404 problem
- How to have the same url structure for both a CPT and a Taxonomy?
- How to create custom url structure based on custom post type rewrite slug, taxonomy and category slug?
- Can’t remove front from permalinks for custom taxonomy category page
- Using taxonomy term in CPT permalink – Pages 404’s
- Programmatically rewriting slug through functions.php but returns 404
- Custom Permalinks with CPT and Hierarchical Taxonomies
- Blog posts for custom post type only
- Custom Permalink Structure for Custom Post Type, Custom Taxonomy, Under a page
- Custom post type archive pagination 404
- Custom post type, permalinks, taxonomies and blog posts
- Custom post type permalink returns 404
- Ignoring slug capitalization on rewrite rule for custom post type archive page
- 404 in custom post type feed with mistake permalink
- Add a permalink variable onto custom post type URL after post name slug
- How to solve this custom post type goes to 404 page?
- Get term name without a foreach loop
- How to query 2 custom post types that need to share a slug?
- How to change path for default WordPress blog posts?
- Custom post type as child of page
- How to implement a different permalink structure for custom post type?
- Custom Post Type permalink without /%day%/ and/or /%postname%/
- WordPress custom permalink and archive link for custom post type
- Enabling permalinks disables custom page template
- Need to return a string as permalink insted of str_replace
- Query Custom Posts – Add To Selection
- How to setup different permlalinks for posts and pages?
- Add unique ID number to end of permalink
- Custom Post Type Child Won’t Come Through With Pretty Permalinks
- Disable permalinks, but allow RSS feeds
- Set priority to permalinks
- How to keep WP from creating a “single-post” page and let the user input the link of the post in the dashboard?
- Changing CPT permalink
- CPT relations use in permalinks under single post type
- How can I get custom post types to recognize pretty permalink variables?
- Enabling hierarchical in a Custom Post Type gives error 404
- Missing permalink for custom post type
- Custom post type and taxonomy same slug
- How to structure a website with custom post types and custom taxonomies?
- WordPress page not showing up – replaced with last 10 posts?
- How to show data content from single page which is from custom post type?
- How to get adjacent_post custom_field value
- Custom Post Type Taxonomy – Permalinks generating, but posts not found
- DIVs not showing correctly on CPT?
- Display Taxonomy Term for CPT on single-CPT.php
- Custom taxonomy in custom post type archive with pagination
- Custom post type with parent page? Possible?
- Permalink clashing with Custom Post Type rewrite rule
- Permalink Trouble with Custom Post Type
- How to make a list of posts displaying them 5 by 5 with a “next posts” link?
- Custom post types not using archive structure
- Dynamically change Custom Post Type Template OR Change Permalink?
- Single and Archive Pages with Custom Post Type
- Custom post type and category permalinks
- Wp-theme Development
- Custom post type with custom parent prefix slug