Forums

[resolved] Conditional Tag code not working (3 posts)

  1. Jonas Grumby
    Member
    Posted 2 years ago #

    I'm trying to get a client's "Blog" page to display a different right sidebar than the rest of the pages. I entered this into the page.php file of the template:

    Where it used to say:

    <?php include ('sidebar2.php'); ?>

    I changed it to:

    <?php
      if (is_page("blog")) {
      echo '<?php include ('sidebar2.php'); ?>';
      } else {
       echo '<?php include ('sidebar3.php'); ?>';
      }
    ?>

    This code was taken directly from a site that it works on. All I changed is what is in the echo '' part and removed some elseif lines.

    Can anyone tell me why this isn't working? I think it's because I have <?php ?> in there more than once but don't know how else to write it.

    Thanks

  2. Jonas Grumby
    Member
    Posted 2 years ago #

    Found the code by searching Google:

    <?php if ( is_page('blog') ) { ?>
    <?php include(TEMPLATEPATH.'/sidebar2.php');?>
    <?php } else { ?>
    <?php include(TEMPLATEPATH.'/sidebar3.php');?>
    <?php } ?>

    Thanks!

  3. Samuel B
    moderator
    Posted 2 years ago #

    edit - ha beat me to it

Topic Closed

This topic has been closed to new replies.

About this Topic