• Resolved fibnok

    (@fibnok)


    I need to set up my blog to use different sidebars based on post number. I modified my “single.php” file with the following code:

    <?php
    if (is_single(’30’))
    get_sidebar30();
    else get_sidebar();
    ?>

    I expected this to get “sidebar30” if post30=true, otherwise it would grab the standard sidebar. Well, the “else” part of the statement works, but the “if (is_single(’30’)) get_sidebar30();” returns a blank sidebar.

    The only difference between sidebar.php and sidebar30.php is an iframe element grabbing an amazon product. But when I load post 30, the sidebar is completely blank.

    Any ideas?

    I’m using the theme “fluid-blue-10” with widgets enabled. Not sure if that makes a difference.

    thanks,

    Datamonkey

Viewing 3 replies - 1 through 3 (of 3 total)
  • get_sidebar30();

    That will never work since get_sidebar30 is NOT a function defined in the WP core files (as opposed to get_sidebar, which IS a function written in the core files).

    To include other template files that reside in your theme folder, use this:
    <?php include (TEMPLATEPATH . '/yourfile.php'); ?>

    Use it as it is, just replace the filename!

    Thread Starter fibnok

    (@fibnok)

    Hey Moshu,

    Thanks for the feedback, but I can’t get it to work. Here is the code I’m using:

    <?php
    if (is_single(’30’))
    <?php include (TEMPLATEPATH . ‘/sidebar30.php’); ?>
    else get_sidebar();
    ?>

    The sidebar still shows up completly blank. Just to make sure I hadn’t messed up the file “sidebar30.php” I modified the code to include “sidebar.php”, the standard sidebar. Can you see any errors in the code?

    thanks,

    Datamonkey

    Thread Starter fibnok

    (@fibnok)

    Never mind. Got it. Here is the code that works.

    <?php
    if (is_single(’30’))
    include (TEMPLATEPATH . ‘/sidebar30.php’);
    else get_sidebar();
    ?>

    Thanks for your help, Moshu.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Using Multiple Side Bars with an if/else statement’ is closed to new replies.