Function get_template_part()
load file only from theme directory (or child theme).
There is no filter or action hook that would change this behavior.
You will need to write your own get_template_part()
variant to load files from the plugin directory (replace the locate_template()
call from the original function). Or write an explicit:
$query->the_post();
include plugin_dir_path( __FILE__ ) . 'single-products.php';
Related Posts:
- Where to put my code: plugin or functions.php?
- How to add custom content template part for a custom post type on main query using a plugin
- Make custom post type display as a page
- Form action/link to render a plugin in WordPress front-end
- Modify a plugin function output from another plugin
- Content in WP Editor displayed below CPT shortcode [duplicate]
- How to display the post using a shortcode in WordPress?
- How to seperate posts by categories?
- Custom meta box in editor of custom post type not working
- Shortcode error
- How to separate posts by categories?
- 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
- Display custom post type with shortcode
- Pre get posts for single post
- Pull Two Posts Into Custom Post Type `single-cpt.php`
- is_singular() not working if called via callback function of admin-ajax.php
- Render a different post/template from within the template_include action?
- Post Rank on Single Post page based on custom field
- Displaying Meta Box Image
- How to register custom post types in a plugin?
- Actions that Run on Admin Edit Page Load After Posts Are Queried
- How can i list custom post type categories?
- Custom role capabilities to administrator not taking effect (no plugin)
- How could I create a ‘private comments’ section on a custom post type?
- Post the content of a specific “Custom Post Type” post within a post using a shortcode
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- How would I create a shortcode to display a custom post within a page or regular post?
- Issue with pre_get_posts on custom post type archive pages
- Shortcode insertion in tab
- How to call custom single post?
- Metadata for a taxonomy – is there any WordPress way of doing this?
- get_object_taxonomies() returns empty array for custom post type
- Unable to get Custom Plugin Options data
- How to render a custom post type template with custom fields using shortcode
- Add Custom Post type menu to another menu in specific location
- Problems wp_insert_post and save_posts filter
- Cant get paginations on single.php to work with my custom post types
- wordpress remove views from action links in a custom post
- 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
- List of users that clicked a ‘Join’ button at single post
- Get Specific Template Part if Custom Field is Some Value
- Inserting custom fields into single.php
- Shortcode leaves no space for other elements?
- Show current custom taxonomy
- How to insert data into meta box from another plugin?
- Custom shortcode works in Elementor editor but not on frontend
- 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
- Run shortcode in custom script in wp_head if post type is CPT ‘Jobs’
- How to show custom field on specific custom post type posts only when filled
- Shortcode to return single custom post based on post taxonomy
- Add post type pages with plugin
- adding custom post type “name” to single template
- Change post type depending on shortcode
- How to List Custom Post Type Titles Based on Theirs Taxonomy Terms Inside a Nested Loop
- Most viewed post of custom post type
- display custom portfolio tags
- Shortcode in pages or tempate files for custom post type
- Is there a (preferable built-in) way to check what custom queries are used in a theme?
- Custom post type page with parameter
- Custom post type category link redirecting to 404 page
- How to show the post which checkbox is not selected
- php dynamic content inside shortcode
- Replace Content of Sidebar on Custom Post Type
- How to upload an image to a custom post type
- Custom post type shortcode
- I have a random letter appearing before my content. Where to start looking for the cause?
- How can I write slugs / permalinks as: custom post type -> custom taxonomy and custom post type -> custom taxonomy (one CPT and many taxo)?
- Custom Post type shortcodes
- Correct way to register custom post type from external php file?
- Add an array as post content dynamically
- How save custom meta type posts multicheck grouped by taxonomy (with CMB2) [closed]
- Not Able to List CPT Based on Taxonomy Term
- How to reset HTML filter input fields on CPT list page?
- How to get adjacent_post custom_field value
- Single Page of Custom Post Type Not Showing the Content Of post
- Simple renaming my custom post type set with a plugin doesn’t work?
- How to Fix Custom WordPress Loop with Pagination on Single Post View?
- get_post_types doesn’t work in plugin
- Show Templates in Custom Post Type Editor
- Associate custom categories to different user IDs
- 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
- adding a shortcode into a custom post type
- query_post while (have post) get_template_part()?
- Nested loop called with shortcode duplicating the content above the main loop
- Add number in increment of one to DIV ID
- How to create an upload page (front side)
- WordPress Roles
- How to change post cpt with submit button?
- Custom Post Type featured option