Support » Themes and Templates » 2 sidebars, how do i?

  • I have a theme that lists sub pages on the sidebar if they are available. I only want sub pages on some of my pages, so here is what I did to try and fix it. I created a template called “no sub pages” that pulled a sidebar2 instead of the original sidebar. When I do this, i get the following error:

    Fatal error: Call to a member function on a non-object in /homepages/1/d248900016/htdocs/wp-content/themes/mushblue-10/sidebar2.php on line 20

    I have added this in functions.php:


    function sidebar1(){
    include (TEMPLATEPATH . “/sidebar.php”);

    function sidebar2(){
    include (TEMPLATEPATH . “/sidebar2.php”);

    if ( function_exists(‘register_sidebar’) )
    ‘before_widget’ => ”,
    ‘after_widget’ => ”,
    ‘before_title’ => ‘<h2>’,
    ‘after_title’ => ‘</h2>’,
    ‘before_widget’ => ”,
    ‘after_widget’ => ”,
    ‘before_title’ => ‘<h2>’,
    ‘after_title’ => ‘</h2>’,

    Ideas as to where I go next? What am i missing?

    I call the 2nd sidebar like this, <?php sidebar2(); ?>

    Also, here is the code on the 1st sidebar that pulls the subpages:

  • <h3 class=”sidebartitle”><?php echo $parent_title; ?> <?php _e(‘Subpages’); ?></h3>
    <ul class=”list-page”>
    <?php wp_list_pages(‘sort_column=menu_order&title_li=&child_of=’. $parent_id); ?>
  • I just removed that code in sidebar2.

Viewing 13 replies - 1 through 13 (of 13 total)
  • I’m using two sidebars on a test site. I’ll show you my code and hope that helps you.


    if ( function_exists(‘register_sidebar’) )
    ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’,
    ‘after_widget’ => ”,
    ‘before_title’ => ‘<h2>’,
    ‘after_title’ => ‘</h2>’,
    ‘before_widget’ => ‘<div class=”block2″>’,
    ‘after_widget’ => ‘</div>’,
    ‘before_title’ => ”,
    ‘after_title’ => ”,

    My main sidebar is named sidebar and I have it called on sidebar.php.


    <div id=”sidebar”>
    <ul id=”sidelist”>

    <?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(‘sidebar’) ) : ?>
    <?php endif; ?>

    <!– end sidelist –>
    </div><!– end sidebar –>

    My second sidebar is loaded into my footer.php, but you could work it into a side-by-side if you want.


    <div id=”info”>

    <?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(‘below’) ) : ?>
    <?php endif; ?>

    </div> <!– end info –>

    I hope that helps!

    thanks for that.

    am i pulling the sidebar correctly in my template by using this?

    <?php sidebar2(); ?>

    If you are using dynamic sidebars, that really isn’t the best way.

    I’m not fantastic with php, but I don’t think that code is properly pulling what it needs to.

    also, here is line #20 where the error is:

    if ($wpdb->get_results(“SELECT * FROM $wpdb->posts WHERE post_parent = ‘$parent_id’ AND post_type != ‘attachment'”)) {

    ok, i just used what was already in my page.php and mirrored that.

    A lot of it might have something to do with what theme you are using.

    If you copied it, then I’m not exactly sure why it isn’t working.

    I’m not too familiar with the code from line 20.

    What theme are you using? I’d like to take a look.

    Do you want the sidebars right next to each other?

    If so, you might try another theme that already had three columns to make the editing easier.

    no, i don’t want them next to each other.

    on one page i want sidebar1 to be pulled.

    on another page i want sidebar2 to be pulled.

    For example:

    The home page shows sidebar1 and any other page shows sidebar2.

    Is that right?

    You might try:

    <?php if (is_home()) {
    include (TEMPLATEPATH . "/sidebar1.php");
    } else {
    include (TEMPLATEPATH . "/sidebar2.php");

    the only pages that will show sidebar2 is the ones that have the “no sub pages” template assigned to them.

    I don’t know how to apply conditional tags to pages with certain templates.

    The above fix is the only one that I know of that might help you.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘2 sidebars, how do i?’ is closed to new replies.