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]
- Block Theme: How to use a different template on front page vs paginated pages?
- Customizing a WordPress theme without changing it?
- How to Link External jQuery/Javascript files with WordPress
- How can I get the title attribute from get_the_post_thumbnail()?
- Dynamic template serving, change theme_root using add_filter from current theme
- 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?
- Is it possible to access Gutenbergs reusable blocks in CPT block templates?
- Splitting an Evolving Site into Multiple Sites, or Maintaining as One Site?
- 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?
- Custom Page Template [closed]
- 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 Do I Find & Remove H1 From Site-Title-Wrapper? [closed]
- How to edit the font color of the H1 on a single page?
- How To Show Different Footers For Different Post Types Pages?
- 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?
- Index page is not working
- 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?
- Custom fields not displaying on front end
- My blog suddenly can’t find my stylesheet?
- Customizing 1 theme for multiple blogs in a multisite setup
- Is there any way to modify images from a theme using the web interface?
- Custom theme – pages in menu
- remove preloader in WordPress theme [closed]
- Please help me clear my confusions about WordPress
- WordPress 2022 template, how to see the blocks added in post template on post edit?
- Can I use non-wordpress themes in WordPress?
- WordPress keeps switching back to empty template
- Removing a widget via theme editor
- How do I bring a page template into a new theme with separate styling?
- 12 column grid layout
- wordpress custom posts page not showing
- How do I target this page specifically?
- Custom CSS is overwritten by WordPress?
- Default and warning messages & no login
- dynamic image path within a javascript file
- WordPress Twenty-Fourteen: How to Remove Home Page Header Image from Other Pages
- Display ads by location [closed]
- WordPress Dashboard Problem [closed]
- Use another theme template in my theme
- Show posts from all categories
- Redirect Every Instance of The Author Template Pages to Custom Author Pages
- Getting page/category content to show up in my custom page template
- 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
- What is the template file for topic layouts in bbPress?
- Will this js code work in a page template?
- Custom single page based on which custom page template is selected
- How to find out which template the HTML content comes from?
- How to modify/ customise NextGen Gallery’s templates? [closed]
- separate home page into separate pages
- Theme Options Menu Item – Permission Issue
- Automatically delete default posts and pages on theme install?
- Overwrite template-tags.php in child theme
- 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
- Homepage not loading correctly, only after refreshing
- How to clone a theme template from within WordPress? [closed]
- Create a page for each database table entries
- Edit Page button is gone
- Why do pages look good when logged in to Admin but not when logged out
- Does WordPress maintain revisions for index.html template?
- what use have double styles in index.html?