Yes, it’s possible. You’ll need to use the template_include filter.
To return a different template for a custom post type of “my_custom_post_type”, you could do something like this:
add_filter( 'template_include', 'wpse_272261_template_include', 100 );
function wpse_272261_template_include( $template ) {
if ( is_singular( [ 'my_custom_post_type' ] ) ) return PATH_TO . 'template.php';
return $template;
}
Related Posts:
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- What process do you use for WordPress development? [closed]
- Why does WordPress use outdated jQuery v1.12.4?
- What is the advantage of using wp_mail?
- Should Plugin Folders Include a Blank index.php File?
- Should I create a theme or a plugin?
- Include third party Javascript library which is not included in WordPress
- Where do I start from
- WP 3.3 Tooltips API?
- Check for featured image in WP_Query
- wp_remote_get doesn’t work with secure connections https?
- Authoritative answer on which boots first – Plugins or Themes?
- How to Add Font Awesome Icons to WordPress Menus?
- How to Use WordPress Color Picker API in Custom Post Type Metabox
- Get file headers in custom file
- Custom theme sufficient or custom plugin neccessary for this feature set?
- How to create custom home page via plugin?
- How to: get main plugin/theme file?
- How to debug WordPress correctly?
- add_theme_support using a plugin
- Featured Image not showing in admin
- What is the difference between these two methods of writing $ instead of jQuery in WordPress [closed]
- Whats the difference between blog_info(‘stylesheet_url’) difference get_stylesheet_uri()
- Paging on a future post loop?
- Is there any way to have Featured Text, as opposed to Featured Image?
- How to check if a stylesheet is already loaded?
- Find source of notice / warning / errors efficiently
- Problem with is_active_sidebar?
- StackExchange clone using WordPress?
- Sharing common functionality (functions, template parts) between plugins and themes?
- Change template dynamically
- WordPress add_admin_page not working even parameters are correct?
- Customizer: widget-synced triggers twice
- Change the ‘published on’ text?
- Get Current Menu Location inside Nav_Walker
- Howto: Use Custom Post Types as Submenu Items in Admin
- Extending theme PHP class in plugin
- How to access noticeOperations from withNotices
- How to get boolean value from register_meta properly?
- what is the difference between these phares?
- How to export post meta with images in wordpress
- Password field is empty when using wp_signon();
- How to limit number of number of categories displayed by categories widget
- Strange Situation When Try To Retrieve Github Gist Using wp_remote_get
- How to hide or rename “X” and “x-child” references in website source?
- How to Control CSS of Admin On Creating only a Specific Custom Post Type
- Can’t change the style of a submit input type? [closed]
- Make a plugin page out of influence of the theme’s style
- Custom entity search and display
- Template directory in plugin
- 400 Bad Request, in wordpress theme development, wp_ajax
- Issue on Setting $icon_url Parameter on WP add_menu_page()
- unable to wp_enqueue_script(‘suggest’);
- Drawing the line between theme & plugin on large scale bespoke projects
- Apply styles to blockquote element with the WYSIWYG editor
- How to add plugin options in wp editor page
- Ajax: Populate with content from a post’s ID not working – duplicating current page html instead
- Gutenberg blocks error: Each child in a list should have a unique “key” prop
- Create fixed static pages
- How to replace settings in WordPress plugin from a theme
- Save temporary registration data
- Setting a post’s category
- Change the behaviour of a button
- Configuring Xdebug with docker compose
- Why my theme’s css not working on another site
- How to show comments from different Plugins to same post type?
- Google Web Core Vitals – management, how to in wordpress and advice
- How to add quick edit on the list of users to edit custom fields?
- Impossible to declare box-shadow with wp.customize?
- Want to know how to reveal a WordPress theme, considering the theme name is hidden?
- Override category archive page title (not the head title)
- Redirection from a specific page for users logged in but not with membership
- Metabox types list
- 400 Bad Request and illegal invocation in wp_ajax based on processData set to false or true
- Rate limiting ajax requests in WordPress
- How do I make two shortcode use the same id and increment it when I use them multiple times?
- Post Pagination does not working on WP-Query
- How to CRUD from wordpress database in wordpress theme?
- Dynamic sidebar areas not working on the Theme Customizer
- Caption Shortcode: what filter to change the image size?
- Font Awesome stopped showing icons, shows &# text instead [closed]
- Merge Codes using redux framework
- Managing Custom Designed Content
- Issue on Getting Images URL of the Post Gallery
- Best practice: What belongs in theme and what in plugin for large eCommerce website
- variable created in page.php is null inside of header.php
- Issue on Getting WP Gallery Items In cpt-single.php As Attachments
- Generate activation url
- Updating Style From WP Options Setting Page
- WordPress Beginer to Guru [duplicate]
- Saving multiple fields as array
- append code after the_content not working
- Problem with Poedit [closed]
- Is Explicit Versioning a better alternative to Semantic Versioning for wordpress?
- Invalid Menu Items
- Gutenberg text field validation
- How to get the value entered in the input field in wordpres
- Why isn’t custom sidebar panel not showing up in the Gutenberg Editor?
- How to customize password reset message page on success if no error in password reset
- WordPress Block with Interactivity API e Preact Component