• Quick question:

    Roughly, how would I go about making each page display a bespoke sidebar? Would I need to edit my sidebar.php and add in some if, then, else tom foolery to make it look what the current page is then display accordingly?

    I’m not in any great hurry, I may just want to do this in the future.

    Thanks.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter minute44

    (@minute44)

    Bump!

    I was thinking along these lines… I could have say 3 different sidebar files: sidebar.php, sidebar2.php and sidebar3.php

    How would I get say archive.php to pull sidebar2.php and a singe post pull sidebar3.php ??

    Is this the way i should approach this?

    That doesn’t sound too hard. Look in your index.php, archive.php and single.php. On the bottom it says “get sidebar”. I don’t know if it’s as easy as to make it into “get sidebar1”, but I guess you’ll let us know when you find out.

    [edit] :
    I took a quick look at my theme and the command is actually <?php get_sidebar(); ?>. I think what I said above was a bit too easily thought, but I still think that making <?php get_sidebar1(); ?> would be worth the try.

    Thread Starter minute44

    (@minute44)

    ah well, I thought that too but it doesn’t just call the file it uses a function called get_sitebar. I’m worried i’d need to create seperate functions for the different sidebar PHP files.

    Ok, in that case a more expert user better respond…
    (and I was editing while you responded btw.).

    You could do this with conditional tags, and a single sidebar file. For example

    <? php if (is_archive()){ ?>
    Custom code
    <? php elseif (is_page()) { ?>
    Other code
    <? php } ?>

    Just a quick example your code might be different.

    There may be some more hints elsewhere on the forum.

    I haven’t tried it yet, but you could try the WP Widget Changer plugin.

    Thread Starter minute44

    (@minute44)

    Ok, got it working roughly with this:

    <?php if (is_home()) {
    include (TEMPLATEPATH . "/sidebarmain.php");
    
    } else {
    include (TEMPLATEPATH . "/sidebargalleries.php");
    }
    ?>

    Now the next step. How would I edit that code so that all pages show sidebarmain.php except my galleries page or any of it’s children?

    Thread Starter minute44

    (@minute44)

    bump

    re-bump — anyone want to code a sidebar switcher plugin that would let you choose sidebars in the Admin>write area? Simple, necessary thing!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Making each page display a different sidebar.’ is closed to new replies.