WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] unique sidebar for pages (4 posts)

  1. 24lover
    Member
    Posted 3 years ago #

    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...

  2. Gisha James
    Member
    Posted 3 years ago #

    <?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.

  3. 24lover
    Member
    Posted 3 years ago #

    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?

  4. 24lover
    Member
    Posted 3 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.