I’m trying to make a plugin that will change the behavior of a theme.
In the theme file I have a get_template_part('libs/templates/user_menu');
.
I want to make my plugin “force” the get_template_part
to return another slug file (a path to a file in the plugin’s folder).
So far this is my code inside the plugin:
function wpse21352_template_part_cb( $slug )
{
if(slug == 'user_menu') {
return WP_PLUGIN_URL.'/'.$slug;
} else {
return $slug;
}
}
do_action( "get_template_part_user_menu", 'user_menu' );
add_action( 'wpse21352_template_part_cb', 'get_template_part_user_menu', 10, 1 );
Well, I handle this issue by adding some code above get_template_part() function in theme as:
in my plugin:
may this will help you