I’m pretty sure you could also do what you want by filtering template_include
. This is super-untested, but maybe this can get you headed in the right direction:
function wpse53871( $template ) {
global $post;
// check if is a Post and in the 'scott' category
if( is_single( $post->ID ) && has_category( 'scott', $post ) ) {
return get_template_part( 'page' );
} else {
return $template;
}
}
add_filter( 'locate_template', 'wpse52871' );
Here’s another example of the filter in use.
Additional
You can also add a filter to single_template
add_filter( 'single_template', 'wpse53871' );
Related Posts:
- Template Hierarchy: confused with index.php, front-page.php, home.php
- How to use a specific category archive index as the site front page?
- Overriding default template if page slug and post type are same
- Load custom template for specific GET parameter
- where is the code that executes the template hierarchy?
- WordPress Page Hierarchy
- How to force sub-product-category to use the parent category template
- How to determine the template loaded when you are not an Admin?
- Template hierarchy override
- How to define the template priority between built-in categories and custom taxonomies?
- What is the difference between the “Main Index Template”(index.php) and HomePage(front-page.php)
- About template hierarchy
- Front-Page.php and Index.php
- Displaying a custom post type and an archive page
- Which page is referring to *all posts by author*?
- How to determine top level template file in functions.php? [duplicate]
- Get the current hierarchy php page
- Custom taxonomy query broken after upgrade to 4.4
- CPT Template Not Showing – Getting 404
- Create “File-less” Page Template in Functions.php
- Overide get_template_part( ‘partials/post’, ‘sidebar’ ); with a plugin
- How to make child categories recognize parent’s template displays
- Template for specific post of custom post type
- How can I set up a category “overview” page?
- LOST in WP Template Hireachy
- How to Handle CSS for Multiple Header header.php Files?
- page_template toggle between 2 templates + 2 permalinks for same post
- Static Front Page problem
- index.php template is used instead of blog page
- Single page template for custom post_type
- Trying to manage templates on a blog with lots of custom taxonomies
- is_archive() content being shown instead of is_category()
- How to apply a custom template for posts by default?
- WordPress Template Hierarchy
- Which php file lists all the post of a category
- Displaying all Video Post Formats to Page
- Custom post type and taxonomy permalinks – Structure
- Custom Taxonomy term archive template
- For custom templates, is it better to use `template_include` or `type_template`?
- When a link doesn’t exist, how to tell WordPress what to do? (404 Error Page)
- Is there any way to get all the name or slug of template parts used in a page?
- Hook to override title, image and content
- Manipulating show_on_front, page_on_front, page_for_posts and template hierarchy
- Category-slug.php not being used
- Is there a way to set different post templates for parent posts and child posts in the same post type?
- How to Arrange PHP Files to Allow for Multiple Types of Pages?
- How do I create a custom archive page depending on the custom taxonomy type?
- WordPress Pagination changes my template
- How to show single category archive
- Having trouble with Template hierarchy. I Need to create a set of pages that drill down from states to specific locations
- How to Rewrite Taxonomy URL to Include the Post Type as the Second Segment of the URL?
- All top-level pages are using index.php as template
- Is there a template file to list all terms of a given custom taxonomy?
- How to load parent theme template parts in child theme
- Selected template is not respected for home page in WordPress
- How does WordPress choose archive type template?
- Will renaming a `content.php` file cause any problems?
- how to force tag page layout to use same as search layout?
- Custom post type not respecting template hierarchy
- get_month_link uses what wordpress template?
- Taxonomy-$taxonomy-$term not working
- understanding theme hierarchy
- Differentiation between index.php and page.php
- standard custom page template hierarchy for plugins
- Single-page.php template file name not shown
- inserting content of 1 Post to in another with a template hierarchy
- How to display custom post type?
- Different Loop for tag pages?
- WordPress sub taxonomy template
- Archive-custome_post.php template not working
- How to link to the page displayed by home.php?
- loading custom registration template
- Using index.php as page template
- Overwriting TwentyTwelve template file with child theme template, but lower in the hierarchy
- Help Understanding Template Hierarchy
- Custom post types templates
- Is it possible to set archive.php instead of index.php to display blog?
- WordPress custom pages in a folder
- How to Override Page Template if URL matches query?
- Assign template to custom page type?
- Overriding the template files using a plugin for all themes
- BuddyPress : how can I call the template WordPress would have chosen (template hierarchy)?
- How can I make custom page templates work on child theme?
- Static page won’t identify template
- More than one search results page template for two searches on site
- taxonomy – templates are not loading
- Templates for CPT not working
- Different templates for each category level
- bbPress: modifying template for forum index
- Page has no template
- Custom Post Type Archive – archive.php is present, but it is not being used
- Custom Homepage As Single Page or Custom Post Type?
- How to stop the search results from loading the wrong template?
- Show a custom template, no matter the page being viewed, if the user is not logged in
- Most efficient way to have 1 template for parent, 1 template for child categories?
- URL Rewrite Adjustment for Custom Post Type causes template to revert to index.php
- CPT Template Not Showing – Getting 404
- Template files not working for archives and categories
- What is the point of using archive.php instead of index.php?
- I’m building a WordPress theme and noticed that the 404 page template runs along with the corresponding templates for each page. Any idea why?