Ok i done by my own.
I delete all above code and write this code. It works perfectly for me
Code:
function template_chooser($template){
global $wp_query;
$plugindir = dirname(__FILE__);
$post_type = get_query_var('post_type');
if( $post_type == 'product' ){
return $plugindir . '/themefiles/single-product.php';
}
if (is_tax('prodcategories')) {
return $plugindir . '/themefiles/taxonomy-prodcategories.php';
}
return $template;
}
add_filter('template_include', 'template_chooser');
Related Posts:
- Submit to itself don’t work
- I can’t fetch query parameters ($_GET parameters) with get_query_var
- Change Password Hint
- Second select list values are not saved after clicking update
- Use wc_enqueue_js only on specific pages – nested add_action
- How to use a frontend URL with a Plugin
- Insert code when users come from an specific referer
- Theme url in all plugin pages
- Change links automatically to affiliate links
- Why WordPress architecture is not pure object oriented and it don’t use MVC pattern? [closed]
- How to access function from outside of a class within this class in WP plugin?
- How can i display post loop in table format?
- Page Reloads Before AJAX Request Finishes
- PHP can I add line numbers to file_get_contents()
- Add htaccess rules with insert_with_markers at beginning of htaccess
- Insert array data on plugin activation
- Adding Default Settings to Theme My Login plugin
- WordPress ajax doesn’t display object method on jQuery .change() function
- what is the best practice to add new field to an api route
- filter default query to show just selected level of child pages in wordpress
- Use custom post type for a store locator
- How do I programmatically set a user as spam in BuddyPress? [closed]
- Redirect undesirable domain
- How to make my custom widget appear within WordPress widgets? Plugin development
- WP CRON duplicate wp_insert_post with has < and > tag
- How to send Ajax request from my plugin in admin dashboard?
- AJAX success response is not working but it’s saving my changes
- Best practice for show data to one specific user?
- Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]
- How to redirect users based on role and content of redirect_to?
- Asynchronous multiple requests 401 Unauthorized
- Using data sent via AJAX in multiple functions on a WP plugin
- What does -> mean in WordPress?
- Usage of call back function of add_meta_box()
- Change product_base programmatically
- WordPress redirect redirecting too many times or not at all
- How to add the sidebar to all the pages except the home page? [closed]
- WordPress shortcode returns the data before
- Plugin development and composer
- How to Schedule Cronjobs for start of every month and year
- Set default Database Storage Engine when creating tables with plugins?
- custom post type with role Vendor
- Execute Jquery when a specific page in my plugin is loading
- How can I get plugin meta data without knowing the plugin folder?
- calling admin-ajax.php from admin-ajax.php
- Flatten Responses returned via WP REST API via WP_Error for obfuscation
- Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
- WordPress can’t use ZipArchive
- WordPress url By country code?
- How to change basename url for wp-admin?
- Only the first image uploads
- WordPress loading progess – wp-blog-header.php
- Illegal string offset checkbox
- Implementing a multilingual WordPress site by installing several instances of WordPress and redirecting
- Custom plugin: how do I call a PHP file if settings option is set to true?
- Trying to use a variable to set image width
- wp_update_post gives 500 internal error
- Remove all feeds and return custom 404 page
- Submit remote form to wordpress REST API and save data to custom post type
- Foreach Loop Of Post Types With Nested If Else If Not Completing Process
- How to identify which php file a plugin is using on page load?
- dashboard widget form not submit mails
- In a foreach loop, how can I add a meta value if it doesn’t exist?
- Looping through and combining calls to Woocommerce REST API
- Should I use wp_cache in my plugin to make it faster?
- register_setting not save checkbox
- How to access this jQuery/AJAX data in a PHP file/WordPress plugin
- post_exists stops working in a scheduled event
- register dependency css and js inside a plugin class
- Redirect User when they click Menu Option
- When I create a new custom post type, it replaces the old post type
- How does one make a URL return dynamic JSON with custom Content Type?
- How to give custom roles the capability to edit one Menu instead of every Menu
- wp-login.php?redirect_to=https problem
- ERR_TOO_MANY_REDIRECTS / To Force SSL Logins and SSL Admin Access
- add menu page in loop menu order
- Add .php to end of all WordPress Pages (multisite)
- defined (‘ABSPATH’) false after AJAX post to other PHP-file
- Override 404 when navigating to single php file
- Getting Member Data From WhishList Member on Register
- Private messaging – Getting and displaying the avatar/url of a message recipient
- I’m writing my first plugin and my echo output is showing up on every page of my wordpress installation
- widget: input the px value from user and use it as inline style in widget function
- Custom post type single page return to listing page
- Create and update Custom Cookie based on multiple GET and POST Values for first time visitors?
- WordPress rewrite question
- Using Nonce for my Form
- Create new folder and upload files to custom folder via wp_handle_upload
- Can’t remove menu items added by plugin
- Issues separating my Plugin pages into different files
- SHARING TO FACEBOOK – FROM DYNAMICALLY GENERATED PAGE
- Link to external page has wordpress blog-url inside
- Implement OAuth2 in custom plugin
- login redirect based on user role not work as expected
- redirect user from login page if is logged
- How to pass and validate nonce in custom REST routes
- How to lock users account until approvation
- Variable ++ in query loop
- ajax problems on loading page [closed]
- WordPress REST API – Custom field not added to pages