locate_template
search template only in themes then to use a file outside themes, you can use the filter template_include
like that
add_filter("template_include", function ($template) {
$post = get_queried_object();
if ( is_single()
&& ("features" === $post->post_type)
) {
// absolute path to the template file
$template = __DIR__ . "/../../template/my_features_template.php";
}
return $template;
});
Related Posts:
- Loading custom page template via plugin
- How to use a dedicated template for the Custom Post Type from a plugin?
- How do I Make a custom post type get a custom post template in a plugin
- How do I create a custom post type for a training CMS in WordPress?
- Using custom page templates with plugin [duplicate]
- How can I load Template file from wordpress plugin
- I want to show a list of posts under specified categories
- I want to show a list of post with title that have link goes to that post and icon under the specific category to which it belongs
- Where to put my code: plugin or functions.php?
- Should I use custom post types or a custom database tables for plugin development?
- What is singular.php?
- Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?
- How do I change the author of a custom post type?
- Custom Post Type Plugin: Where Do I Put The Template?
- Best way to flush_rewrite_rules for custom post type, in a mu-plugins plugin?
- How to Add Custom Taxonomy To Woocommerce Plugin
- Using add_theme_support inside a plugin
- What are the differences between custom post type and custom page templates?
- Page Template as Custom Post Type Archive
- Creating a Custom Post Type as a Plugin? Why?
- Quick edit screen customization
- Mini-Site Strategy
- The Great Plugin Nomenclature Contest of 2011
- Prevent trash/delete action on specific post types
- Setting a custom sub-path for blog without using pages?
- How to add custom content template part for a custom post type on main query using a plugin
- How to completely disable a taxonomy archive on the frontend?
- How do you create an archive for a custom post type from a plugin?
- Add Content to Page without shortcodes
- How to add a button to custom post type’s posts-page
- Why The Init Hook For Custom Post Types
- How to set a fall back template for a custom post type in a plugin?
- Post formats “audio” and “video” only showing in index.php
- Ordering Posts List By Taxonomy Terms?
- How to add multiple images to custom post type?
- Creating a custom public user page
- Creating a Custom Post Type for Inserting Preset Content into Post & Pages?
- wordpress plugin error handling
- WordPress keeps fetching the archive page instead of the template page
- How to get term link that crosses different custom post types?
- register_taxonomy with multiple object type and update_count_callback
- Redirect after deleting post and keep track of pagination
- How to add custom template in plugin?
- How often do you need to register_post_type?
- How to quickly switch custom post type singular template?
- get_edit_post_link() not working as expected when passed id in plugin
- Where to put archive-{post-type}.php
- Render a different post/template from within the template_include action?
- Is flush_rewrite_rules necessary when creating a custom post type? Why?
- Add a Template to a custom post type
- WordPress calls archive page instead of Custom Page Template
- How to sort list of custom posts to get view like a tree of posts under categories and their children’s categories?
- Assign Page Template Within A Custom Post Type
- Dynamic page.php template for custom post types
- Custom post type archive and single.php files not working
- Determine which template-{slug}.php is being loaded
- Page Templates – this code only works for one Custom Post Type
- Pagination on a custom page template
- How to append text to title of Custom Post Type post (without affecting all titles on page)?
- Remove Slug from Custom Post Type results in 404
- WordPress metabox file upload in custom post [duplicate]
- working Custom Post Type and Widget code no longer works when moved from functions.php to plugin
- Custom Post Type – Archive page title
- WordPress custom post type Single.php?
- WordPress custom post action hook
- Unable to filter on field on edit.php page
- Multiple Permalinks for custom post type post
- On clicking on the category name the page is redirecting on 404 pge
- Multiple templates for custom post type
- Insert slider (Custom Post Type) into pages
- WP Query group/order by category name
- Save or update data when custom post published
- Remove POST_TYPE from custom post type permalink
- Uploaded image not appearing in custom post type
- Custom Taxonomy and tax_query Issue?
- Custom Post Types, Page Templates and Pagination. Why do I get a 404 Error?
- How do I create a page template to display a custom post type?
- Use a textarea for a custom post type
- Using posts and postmeta table to store custom Address Book Plugin data
- How to register custom post types in a plugin?
- Actions that Run on Admin Edit Page Load After Posts Are Queried
- How to make an archive page displaying posts in a date range
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Row actions not showing? Why?
- Make custom post type display as a page
- template_redirect not working, apparently for no reason
- Custom Post Type slug same as page name causing a conflict
- How to: add option to add more checkboxes on custom post type
- Custom role capabilities to administrator not taking effect (no plugin)
- How do I add a custom button to my “edit” list? ( edit.php?post_type= ) beside “Add New”
- How to add multiple featured image in meta box in post editor?
- Control Custom Post Type template from a plugin
- How to add notification in the sidebar of the administration panel when a Custom post type is created? [duplicate]
- Hierarchical or Non-hierarchical Custom Post Type in Real World Example
- how to set default value for checkbox in wordpress
- Detect if 1st, 2nd or 3rd level custom page?
- How to append element after thumbnail
- How do I include drag-and-drop in a plugin?
- Create second custom 404 page for selected post type
- How could I create a ‘private comments’ section on a custom post type?