How can I create a different side bar for single posts than for main page?
At the moment I have 2 working one for pages and one for the blog
thanks
this is how it looks in funtions.php
// Register Sidebars
register_sidebar(array('name' => 'Sidebar Blog','id' => 'sidebar-blog'));
register_sidebar(array('name' => 'Sidebar Pages','id' => 'sidebar-pages'));
register_sidebar(array('name' => 'Footer','id' => 'sidebar-footer'));
// Register Menus
register_nav_menu( 'top_navi', 'Top Navigation' );
register_nav_menu( 'main_navi', 'Main Navigation' );
this is how it looks in sidebar.php
<div id="sidebar">
<ul>
<?php
if(is_page() && is_active_sidebar('sidebar-pages')) : dynamic_sidebar('sidebar-pages');
elseif(is_active_sidebar('sidebar-blog')) : dynamic_sidebar('sidebar-blog');
else : ?>
<?php wp_list_categories('title_li=<h2>Categories</h2>'); ?>
<?php wp_list_pages('title_li=<h2>Pages</h2>'); ?>
<li><h2>Archives</h2>
<ul>
<?php wp_get_archives(); ?>
</ul>
</li>
<?php wp_list_bookmarks(); ?>
<?php endif; ?>
</ul>
</div>
Thanks !
I would consider the following …
Register a new sidebar:
Create a new sidebar template:
Then modify your ‘single.php’ template to call the new sidebar (above):
Of course you will need to flesh out the new single view sidebar template file … and the WordPress Template Hierarchy will take care of using your new sidebar on single post views.
Register the sidebars:
Then, in your sidebar template, use the
is_page()
andis_single()
conditional tags: