I've created the plugin that adds custom post type and custom taxonomies for this post type. Templates for the post type and the taxonomies are located in plugin folder.
Now I need to add sidebar for the post type and taxonomies pages. I've tried to use the following code for sidebar:
function mytype_get_sidebar($mytype_sidebar) {
// load sidebar template
if (file_exists(plugin_dir_path(__FILE__) . '/sidebar-mytype.php'))
return plugin_dir_path(__FILE__) . '/sidebar-mytype.php';
// Default return
return $mytype_sidebar;
}
add_filter('get_sidebar', 'mytype_get_sidebar');
And then on the page where the sidebar should be:
get_sidebar ( apply_filters( 'mytype_get_sidebar', '' ) );
But it doesn't work. var_dump returns NULL:
$my = get_sidebar ( apply_filters( 'mytype_get_sidebar', '' ) );
var_dump($my);
Is there any way how to do that?
Thanks in advance.