WordPress.org

Support

Support » Themes and Templates » [Resolved] unique sidebar for pages

[Resolved] unique sidebar for pages

  • hey everyone!
    i was wondering if you could help me with this little problem.
    currently i have this code in page.php

    <?php if ( is_page(‘encountering-conflict’) || $post->post_parent == ‘194’) { ?>
    <?php include(TEMPLATEPATH.’/sidebar-enc.php’);?>

    <?php } else { ?>
    <?php include(TEMPLATEPATH.’/sidebar-alt.php’);?>
    <?php } ?>

    now i would like to add in another conditional tag for another page. So I’d like another unique sidebar for a different page. How would i go about doing this?

    for example, something like:

    <?php if ( is_page(‘encountering-conflict’) || $post->post_parent == ‘194’) { ?>
    <?php include(TEMPLATEPATH.’/sidebar-enc.php’);?>

    <?php if ( is_page(”) || $post->post_parent == ‘##’) { ?>
    <?php include(TEMPLATEPATH.’/sidebar-OTHERSIDEBAR.php’);?>

    <?php } else { ?>
    <?php include(TEMPLATEPATH.’/sidebar-alt.php’);?>
    <?php } ?>

    however, i know this code does not work because i’ve tried it. does anyone know how to code for what i’m trying to do?
    i’m sorry if this is confusing…

Viewing 3 replies - 1 through 3 (of 3 total)
  • <?php if ( is_page('encountering-conflict') || $post->post_parent == '194') { ?>
    <?php include(TEMPLATEPATH.'/sidebar-enc.php'); }?>
    
    <?php elseif ( is_page('') || $post->post_parent == '##') { ?>
    <?php include(TEMPLATEPATH.'/sidebar-OTHERSIDEBAR.php');?>
    
    <?php } else { ?>
    <?php include(TEMPLATEPATH.'/sidebar-alt.php');?>
    <?php } ?>

    Try this code.

    hey gisha james,
    thanks for the reply, but unfortunately it didn’t work.

    i got this instead

    Parse error: syntax error, unexpected T_ELSEIF

    is there another way?

    I found this code on the internet which could work…..

    <?php 
    
    if (is_page('Page Name 1') || $post->post_parent == '##') {
    include (TEMPLATEPATH . '/right-1.php');
    
    } elseif (is_page('Page Name 2') || $post->post_parent == '##') {
    include (TEMPLATEPATH . '/right-2.php');
    
    } elseif (is_page('Page Name 3') || $post->post_parent == '##') {
    include (TEMPLATEPATH . '/right-3.php');
    
    } elseif (is_page('Page Name 4') || $post->post_parent == '##')
    include (TEMPLATEPATH . '/right-4.php');
    
    ?>

    but not sure how i would code for my main sidebar. I understand how to do the unique sidebars with this code, but where would i put this part?

    <?php } else { ?>
    <?php include(TEMPLATEPATH.'/sidebar-alt.php');?>
    <?php } ?>

    sorry if this is confusing again! help would be much appreciated!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] unique sidebar for pages’ is closed to new replies.