Own sidebars for pages
-
Hi
On my blog there is two important pages and of course lots of posts.
Now I’m trying to find a way to show own sidebars for both of pages and still have own for posts.On functions.php there is following lines.
<?php
// register widgetized sidebars
if (function_exists(‘register_sidebar’)) {
register_sidebar(array(‘name’ => ‘Left Sidebar’, ‘before_widget’ => ‘<div id=”%1$s” class=”%2$s”>’, ‘after_widget’ => ‘</div>’, ‘before_title’ => ‘<h4>’, ‘after_title’ => ‘</h4>’, ));
register_sidebar(array(‘name’ => ‘Right Sidebar’, ‘before_widget’ => ‘<div id=”%1$s” class=”%2$s”>’, ‘after_widget’ => ‘</div>’, ‘before_title’ => ‘<h4>’, ‘after_title’ => ‘</h4>’, ));
}And on foother.php
footer.php
<?php get_sidebar(); ?>And my sidebar.php includes
<div id=”sidebar”>
<div id=”sidebar-left”>
<h4><?php _e(‘Categories’); ?></h4>-
<?php wp_list_cats(‘sort_column=name’); ?>
<?php endif; ?>
</div><div id=”sidebar-right”>
<?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar(2) ) : else : ?>
<h4><?php _e(‘Tags’); ?></h4>-
<?php wp_tag_cloud(”); ?>
<?php endif; ?>
</div>So I’m so happy if someone could say what should I do to show own sidebars for every pages?
I read this manual but unfortunately I didn’t understand.
http://codex.wordpress.org/Customizing_Your_Sidebar#New_way_of_adding_sidebars
-
Might look at using Page Templates to control the look of your Pages. Then in your Page Template you can use whatever sidebar for that particular Page:
get_sidebar('mysidebar'); //will use the sidebar-mysidebar.php templateor
get_sidebar('1'); //will use the sidebar-1.php templateRelated:
Stepping Into Template Tags
Stepping Into Templates
Template HierarchyMy problem is that I have a template which have only index.php, not own page templates.
So this is why I’m looking for different way to do this.
Copy your theme’s index.php to page.php and then edit that template.
Review Template Hierarchy to understand what template WordPress will use to render your Pages.
The topic ‘Own sidebars for pages’ is closed to new replies.