You can’t without hooking a filter to recognise the files in your plugin BUT you can hook into the template_include filter and register your own file e.g.
add_filter('template_include', 'my_function_name');
function my_function_name( $template ) {
if( is_post_type_archive( 'post_type' ) ){
$template = dirname( __FILE__ ) . '/templates/archive-post_type.php';
}
if( is_singular( 'post_type' ) ){
$template = dirname( __FILE__ ) . '/templates/single-post_type.php';
}
return $template;
}
I was given this code by another WSE user when I had this exact need
Related Posts:
- Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?
- Custom Post Type Plugin: Where Do I Put The Template?
- How to Add Custom Taxonomy To Woocommerce Plugin
- Creating a Custom Post Type as a Plugin? Why?
- Quick edit screen customization
- Mini-Site Strategy
- Prevent trash/delete action on specific post types
- Loading custom page template via plugin
- Why The Init Hook For Custom Post Types
- register_taxonomy with multiple object type and update_count_callback
- How often do you need to register_post_type?
- Render a different post/template from within the template_include action?
- How to use a dedicated template for the Custom Post Type from a plugin?
- How to append text to title of Custom Post Type post (without affecting all titles on page)?
- Custom Taxonomy and tax_query Issue?
- Use a textarea for a custom post type
- How to register custom post types in a plugin?
- Actions that Run on Admin Edit Page Load After Posts Are Queried
- Custom role capabilities to administrator not taking effect (no plugin)
- Hierarchical or Non-hierarchical Custom Post Type in Real World Example
- How to append element after thumbnail
- How do I include drag-and-drop in a plugin?
- How could I create a ‘private comments’ section on a custom post type?
- How do I alter the position of a Custom Post Type menu item within my plugin admin menu?
- Issue with pre_get_posts on custom post type archive pages
- Get rewrite slug of custom post type in template
- Detect where custom post type is declared
- Metadata for a taxonomy – is there any WordPress way of doing this?
- Hook to override title, image and content
- Why is conditionally loading a custom plugin’s code only on a specific custom post type causing the site content to disappear?
- get_object_taxonomies() returns empty array for custom post type
- No posts found – Custom Post Type show_ui
- Add custom ID to CPT posts only create not update
- Add custom post type as submenu [closed]
- WordPress multiple custom post types capability conflict in a single menu
- Unable to get Custom Plugin Options data
- What is the best practice for displaying my plugin content in themes?
- Add Custom Post type menu to another menu in specific location
- Set a CPT slug as a base name for all the taxonomies
- A custom post type in another post type
- custom comments form for custom post type
- Problems wp_insert_post and save_posts filter
- wordpress remove views from action links in a custom post
- When should I create custom post types?
- Custom post type’s extra fields – how to handle?
- Send a conditional email notification when a custom field value changes in Post Type
- Getting 400 Bad Request on AJAX Call
- Main query not querying any posts in custom taxonomy template
- Show current custom taxonomy
- How to insert data into meta box from another plugin?
- How exclude or skip post type with get_next_post_link
- WordPress: Custom User Role cannot access Custom Post Type | “Sorry, you are not allowed to access this page”
- Add to ‘action’ within post.php to allow more actions when editing a Custom Post Type in a plugin
- Problem with adding custom post type meta to header by plugin
- Create a select metabox that the user can pupolate?
- Types plugin custom post add_action hooks
- Mandatory field in Custom post
- Not Able to Add New Class To CPT Attachment Image
- Custom post type category link redirecting to 404 page
- Translate website without duplicate custom post
- How to store the third party script with HTML code in the wordpress custom input field?
- Orderby custom fields is not working
- How to upload an image to a custom post type
- How to stop the custom post type URL from the google search?
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- Changing CPT permalink
- Get all posts by many custom post types
- ‘Simple’ Reservation System
- Apply a custom Template to a Custom Post Type from within a plugin
- WP_List_Table Inside Metabox Not Working on Clicking Search Button
- Warning , Use of undefined constant PLUGIN_PATH?
- Error when moving custom post type to bin
- Admin metabox with custom post type dropdown option not update choosed input after saving
- Having issue on Loading Meta Data From CSV to CPT
- Correct way to register custom post type from external php file?
- custom data model – link and populate from admin backend
- Custom Post type plugin is using theme single.php and style.css
- Add an array as post content dynamically
- How save custom meta type posts multicheck grouped by taxonomy (with CMB2) [closed]
- php output of generated custom metabox
- Not Able to List CPT Based on Taxonomy Term
- How to reset HTML filter input fields on CPT list page?
- Can’t save custom post type fields
- Simple renaming my custom post type set with a plugin doesn’t work?
- get_post_types doesn’t work in plugin
- Show Templates in Custom Post Type Editor
- Associate custom categories to different user IDs
- Shortcode error
- Render custom taxonomy query as single template
- How to avoid hardcoded text in a custom page template?
- How to use get_sidebar in plugin folder?
- Get term_id for each instance of custom taxonomy
- How to internationalize the sub menu name “categories” in Custom post type?
- Creating a Custom Post Type as a Plugin? Why?
- How to create an upload page (front side)
- WordPress Roles
- How to filter custom post data with AJAX?
- get_post_types() is returning null
- I want to show a list of posts under specified categories
- How to consume external API from WordPress post editor and display the response data in the custom field?