Forums

different sidebars on page.php (3 posts)

  1. rcgaff
    Member
    Posted 2 years ago #

    I modified page.php so that to display a different sidebar on a page titled "The Runner".

    This works fine, but then I want to display the default sidebar for all other pages. I can't the code below to work:

    <?php if(the_title() == "The Runner") get_sidebar('therunner'); ?>
    <?php if(the_title() != "The Runner") get_sidebar(); ?>

    In fact it doesn't seem that any php functions work on page.php - I am beginning to doubt my sanity.

    For example I set $str1 = the_title() and do strlen($str1) it returns zero. I do strlen("The Runner") and it returns zero.

    There must be something basic about the WordPress environment I don't understand.

    Thanks

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Try:

    <?php if( is_page('The Runner') ) get_sidebar('therunner');
    else get_sidebar();?>

    http://codex.wordpress.org/Conditional_Tags

  3. rcgaff
    Member
    Posted 2 years ago #

    I also discovered that if I save a new page template (with the "Template Name:" header) that a dropdown magically shows up to allow me to select one or the other page template.

    I was making it harder than it was.

    Thanks esmi!

Topic Closed

This topic has been closed to new replies.

About this Topic