Sidebar Code Help
-
Hello All,
I have looked over the following code many times, and can’t find what I’m missing to allow each sidebar to operate independently. The code below is from my about page. The problem is every page is still loading the main default sidebar, the widgets in the About sidebar area are not showing up. Any help spotting the coding error causing the problem would be great!sidebar-about.php
<div id="rightsidebar"> <div id="widgets-wrap-sidebar"> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('about-sidebar') ) : endif; ?> </div> </div><!-- rightsidebar end -->About Page Template
<?php get_header(); ?> <div id="contentwrap"> <div id="leftcontent"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php the_content(); ?> <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?> <?php endwhile; endif; ?> </div><!-- leftcontent --> <?php get_sidebar('about-sidebar'); ?> </div><!-- contentwrap --> <?php get_footer(); ?>Functions Code
// Custom Sidebars if ( function_exists('register_sidebar') ) { register_sidebar(array( 'before_widget' => '<div id="%1$s" class="widget-sidebar %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3 class="widget-title">', )); } if ( function_exists('register_sidebar') ) { register_sidebar(array( 'name' => 'Homepage Sidebar', 'id' => 'homepage-sidebar', 'description' => 'Homepage Sidebar', 'before_widget' => '<div id="%1$s" class="widget-sidebar %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3 class="widget-title">', )); } register_sidebar(array( 'name' => 'About Sidebar', 'id' => 'about-sidebar', 'description' => 'About Sidebar', 'before_widget' => '<div id="%1$s" class="widget-sidebar %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3 class="widget-title">', ));
-
this line
<?php get_sidebar('about-sidebar'); ?>tries to call a file ‘sidebar-about-sidebar.php’ which might not exist, and then goes to the default sidebar.php;as you posted yourself, your sidebar file name seems to be ‘sidebar-about.php’ which would need to be called by this code
<?php get_sidebar('about); ?>– http://codex.ww.wp.xz.cn/Function_Reference/get_sidebarI haven’t checked any other code of your post so far…
alchymyth,
Thank you very much, simply changing the get_sidebar to ‘about’ made the widgets on that page to immediately update. That must have been the issue.
I really appreciate the quick help!
The topic ‘Sidebar Code Help’ is closed to new replies.