Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

oriolo on "How to use get_sidebar in plugin folder?"

$
0
0

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.


Viewing all articles
Browse latest Browse all 8245

Trending Articles