I am working on a plugin. In plugin folder, there is a folder 'template' from where i copied the files and paste into 'my_folder' in active theme. They move perfectly. Now when i editing files from the theme they did not edited, but when i edit files from plugin folder, they edited.
I just want that when i edit files from theme the result will show on frontend, not from plugin.
I also use template_include
hook but i don't know where i go wrong.
here is my code:
add_filter('template_include', 'my_template_chooser');
function my_template_chooser($template){
global $wp_query;
$plugindir = dirname(__FILE__);
$post_type = get_query_var('post_type');
if( $post_type == 'my_items' ){
if(file_exists(TEMPLATEPATH . '/my_items/my_items.php')) {
return locate_template('my_items/my_items.php');
} else {
return $plugindir . '/template/my_items.php';
}
}
if( $post_type == 'my_items' && is_single() ){
if(file_exists(TEMPLATEPATH . '/my_items/single-my_items.php')) {
return locate_template('my_items/single-my_items.php');
} else {
return $plugindir . '/template/single-my_items.php';
}
}
if (is_tax('my_items_tags')) {
if(file_exists(TEMPLATEPATH . '/my_items/taxonomy-my_items_tags.php')) {
return locate_template('my_items/taxonomy-my_items_tags.php');
} else {
return $plugindir . '/template/taxonomy-my_items_tags.php';
}
}
return $template;
}
I also try this
return locate_template('my_items/taxonomy-my_items_tags.php');
to
return TEMPLATEPATH .'my_items/taxonomy-my_items_tags.php';
But nothing happen. Please tell me where i am doing wrong