In fact there is, using template_redirect
, which you would put in the functions.php file – Here’s what I use:
function uniquename_default_template() {
if(get_post_type() == 'posttype') : /* You could use is_single() instead of get_post_type() == '' or any type of conditional tag) */
include(TEMPLATEDIR . 'path/to/theme/file.php'); /* You could use TEMPLATEDIR to get a file from a template folder, or PLUGINDIR to get a file from the plugins directory - doesn't support HTTP requests */
exit; endif;
}
add_action('template_redirect', 'uniquename_default_template');
The above code checks for a post_type
called posttype
, if it is, it will include the PHP file specified in the include statement by redirecting the template using the template_redirect
function.
Related Posts:
- Opinions and recommendations on the best barebones base theme [closed]
- Display a specific dynamic sidebar widgets on a specific page
- Customizing page content layout
- Putting two themes together to create a complete site
- Using the same database on another Subdomain
- How to create custom layouts and static pages in themes for clients
- Theme Dev | Convert Template to Theme
- Create a child Theme or custom Theme
- wordpress template page Usage [duplicate]
- How can I get the title attribute from get_the_post_thumbnail()?
- Custom Taxonomy-specific JavaScript
- How to override the “inc” folder (or any folder) in a theme using child theme?
- Any official way to create an admin theme?
- Loading template files from a subfolder in my theme?
- Building useful features into your theme
- Multisite: setting theme and options when a new blog is created
- Editing theme files and access to the Code pages only to super-admin?
- Change Default Image HTML
- WordPress as Backend, Laravel Front End: How to connect Routes?
- How to delete default themes
- Make page template that is just an “include” of another?
- Edit raw HTML of the landing page
- Problem : deletion failed, the theme requested does not exist
- WordPress Fatal error: Call to undefined get_header() in index.php on line 15 [closed]
- Change Theme from Plugin based on query_vars
- How to add template to theme in WP
- How to trigger function on theme delete?
- Setting a static home page and blog page without using the settings
- Can I create multiple instances of the BuddyPress Activity Stream with separate themes? [closed]
- Two Navigation Menus – secondary nav is including main nav
- Possible to put header-{your_custom_template}.php in subdirectory?
- Protect changes made to the theme when updating
- Theme Development Admin Area [closed]
- How to find a file in WordPress themes [closed]
- Custom page template not working
- How to use get_page_by_title() with qTranslate?
- How to set a single theme directory on a multisite blog?
- Child theme Page Template not loading
- Multi-level page hierarchy
- Get WordPress to use another custom “author.php” file (“custom-author-file.php”)
- How to customize core admin pages within a theme?
- Static page not working
- (FES EDD) New vendor submission page is blank
- Own Theme Customizer displays error message when saving, saving still works
- Best practice – pages – ACF or inline coding
- Problem of running development copy of WordPress on WebMatrix?
- Migrating a taxonomy’s tags to the native category
- How to hook up search results page to a back-end page?
- Different logo on homepage
- Selected template is not respected for home page in WordPress
- Tips for managing code when developing a parent theme framework
- Is there a way to upgrade a theme without losing custom templates?
- Advantages of wordpress theme vs wordpress as a backend only [closed]
- How to restore file or theme?
- What’s a good way to unenqueue all scripts for a single template page?
- Template for landing pages
- Trying to uninstall a theme, but it’s hijacking my home page
- Most wp_nav_menu parameters ignored
- Trying to fix a website that was built with WordPress and then taken off of it
- How to add custom meta box when you have a custom page template file
- Create theme for mobile phones and tablets only?
- Create a Page template selector page
- Creating custom page template
- How to use custom page templates in a theme that hides page template option?
- Setting a new default template for the creation of a page
- Conditional config WP_HOME/WP_SITEURL does not update bloginfo(‘template_url’)?
- Create Custom Attachment Template That is Processed from Plugin Folder?
- How to include stylesheet in custom admin using parent_slug
- Multiple sub directories for theme template pages
- How to remove the tripadvisor logo from the wordpress theme?
- My blog suddenly can’t find my stylesheet?
- Custom theme – pages in menu
- remove preloader in WordPress theme [closed]
- Please help me clear my confusions about WordPress
- Removing a widget via theme editor
- How do I target this page specifically?
- Custom CSS is overwritten by WordPress?
- Default and warning messages & no login
- WordPress Twenty-Fourteen: How to Remove Home Page Header Image from Other Pages
- Display ads by location [closed]
- Show posts from all categories
- Redirect Every Instance of The Author Template Pages to Custom Author Pages
- Allow arbitrary text after page URL
- Revamping a WordPress mirror site – and I don’t know where to start!
- Best way to create a page outside of the pages list
- adding a unique page to an existing site
- Work on theme files on a server & browser preview before installing it
- Custom single page based on which custom page template is selected
- How to find out which template the HTML content comes from?
- Static front page displaying twice
- custom post type single page template not working
- What happens to bespoke page template references on theme change?
- How to create an Single-Portfolio page?
- How to add sidebar to homepage programmatically?
- How to apply styles to the custom page template
- Static posts page is not working
- My website is generating weired url parameters of paginated pages
- Get header/footer list for a theme
- Create a page for each database table entries
- Edit Page button is gone