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
- Custom post type and taxonomy permalinks
- Hierarchical permalinks for custom post type and taxonomy
- How to organize hierarchical structure in custom post type with taxonomy (like with categories)
- Make custom post types and pages place nice, re: rewrite
- Custom Post Fields at the beginning of a Custom Permalink
- Flush Rewrite Rules when new site is created on network
- Pretty URLs and custom post types
- Form action doesn’t work if slug isn’t same as custom post title
- How to make permalink structure %category%/%postname%/ work for custom post type?
- set permalink for CPT
- Ignoring slug capitalization on rewrite rule for custom post type archive page
- Lost of query parameter when using permalink
- Custom permalinks rules don’t match and lost of query var in the process
- Custom Post Type – Duplicate Page Slugs
- Rewrite rule for Custom post type Monthly and Yearly archive
- Different results between permalink and query var search
- menu link to custom post_type?
- Custom permalink with child taxonomy terms
- Custom post type Permalinks with hierarchical Taxonomies
- 404 in custom post type feed with mistake permalink
- Not Able To Render Single-CustomPostType.php File
- Add a permalink variable onto custom post type URL after post name slug
- Single page not working for custom post type
- Remove permalink for custom post type
- Permalink misbehaving in Custom Post Types
- Check post on publish for blank title
- single-{post_type}.php not working
- How to solve this custom post type goes to 404 page?
- Get term name without a foreach loop
- Cant get paginations on single.php to work with my custom post types
- Best way to specify “article type” in URL
- Including all post id’s of a custom post type into an array
- Template files for Custom Post Type and Taxonomy
- How to Create Template File for Parent Page of Custom Post Type
- How do you create %post_type%/%postname%/ permalink structure?
- Problems with 404, .htaccess, permalinks and WordPress custom posts locally on Snow Leopard
- Changed permalink structure of CPT – should I redirect?
- How to query 2 custom post types that need to share a slug?
- I’m having trouble getting the permalink sample on my custom post type edit page to work
- How to change path for default WordPress blog posts?
- How to hyperlink content from archive page with custom post-type
- Associate page w/ specific single post template?
- Display custom post types in wp_list_pages
- Can’t use pagination with custom taxonomy
- retrieve permalinks of posts inside custom post type by using post ID
- Custom Permalinks with meta value not working. Why?
- Custom post type as child of page
- Remove custom permalink structure from custom post type without modifying register_post_type() directly
- List of users that clicked a ‘Join’ button at single post
- How to have permalink like domain.com/term/postname?
- Can variables be used to rewrite a Custom Post Type permalink? [duplicate]
- make permalink go to a custom single.php file
- Custom post type permalink sends to 404.php
- Inserting custom fields into single.php
- Post will not load via ajax
- Template for custom post type when taxonomy is in the URL
- One Custom post type 404’s others don’t
- Custom Post Type posts, conflict with posts after add_rewrite_rule to top
- hide specific div on single.php [closed]
- How to change base in tag URL for custom post type, to not use “Custom Structure” set in Permalinks setting?
- Combine multiple CPT names to create valid permalinks
- Permalink problems with custom post type and custom taxonomy
- How to implement a different permalink structure for custom post type?
- How to add a sub directory to WordPress single posts without affecting other post types?
- Set parent for custom post type archive rewrite url
- How to rewrite the beginning and end of the permalink structure in a custom post type?
- Route subpage to Custom Post Type
- Custom Post Type “MUST NOT” be able to search via URL
- Custom post type permalink returns 404 when set to private
- Post URL based on Custom Post Types variables
- Custom Post Type Advanced Slug
- How do I find a way to create a global single.php for a custom post type?
- Dynamic CPT permalink structure based on ACF field value
- Custom post type slug 404
- Custom permalink not working and showing 404 page not error
- Custom Post Type permalink without /%day%/ and/or /%postname%/
- How to use single.php for creating, reading and editing Custom Posts with ACF
- How to filter a custom post type by custom taxonomy without 404
- Can’t access private custom posttype single- or archives-page
- How to get all posts related to particular category name on button click?
- how to retain the ability to modify the post slug after applying a post_type_link filter?
- How to show custom field on specific custom post type posts only when filled
- Rewrite permalink for multiple post types (CPT) with taxonomy term
- Post type Permalink
- get the permalink never return with empty value
- Custom Post Type to replace Woocommerce products – page not found error
- WordPress custom permalink and archive link for custom post type
- Ideas on how to organize a project [closed]
- adding custom post type “name” to single template
- Redirect User From Registration Page To CPT (profile page) with custom url
- Custom Post Type Archive template not being called
- Custom Post Type with Configurable Sidebar via ACF
- Custom Post Types,Permalink and Heirarchy
- Pagination of custom post type leads to 404 error
- trying to show single post but displays all post on a custom post type
- Custom Post Type with modified permalink structure results in 404