sidebar in wordpress
I want to display different dynamic sidebar on开发者_Go百科 different pages, how do I access multiple sidebar on my pages.
Place some form of hook on different pages.
Open sidebar.php
in your themes and check for presence of hook.
You should create files like sidebar-xxxx.php
and include it, using get_sidebar(xxxx)
in the different templates and souhld register them on the functions.php
. If you do not wanna create these files you can register the sidebars on functions.php
and in the sidebar.php use:
global $wp_query;
$page_name = $wp_query->post->post_name;
<ul>
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar-'.$page_name) ) : ?>
<?php endif; ?>
</ul>
create a new sidebar
and you can link them inc with is page
if(is_page(5)) {
include('new-sidebar.php')
}
is page id is 5 lets say thats the id for your home page
just check the ids of your pages and seperate them
if you want them tho show in the page childs to
just write
if(is_page(5) || $post->post_parent) {
include('new-sidebar.php')
}
zou can even write a function either
For different sidebars, i thing you have to do is to create the sidebar which you want as many as you want and save those sidebars as sidebar1.php, sidebar2.php and so on.
And,just include it in the different pages where you want it to display like this:
<?php include('sidebar1.php'); ?>
And, like wise for other sidebars of other pages.
精彩评论