WordPress.org

Forums

script for sidebar.php, so sidebar changes when posts are viewed by category. (2 posts)

  1. RogerDodger
    Member
    Posted 8 years ago #

    Problem:- When visitors view my posts 'by category', I need a sidebar on each category archive page that is customised to that particular category.

    Me:- I've just spend three hours searching and reading up about this - but I'm not a coder, just a "code tweaker and paster". I'm using Worpress 2.0 & classic theme.

    Interim solution:- It seems the best way is some code in sidebar.php, by using "if" and "is" statements. I failed to find _any_ self-contained working 'cut & paste' script for this, so I have slapped together functions in what seems to be the right order... I think what I need should go something like this...

    <?php if

    is_home()
    When the main page is being displayed then offer a the standard sidebar

    is_category('1')
    then display this data in the sidebar
    <div id="menu1">
    Menu 1 content here.
    </div>

    is_category('2')
    then display this data in the sidebar
    <div id="menu2">
    Menu 1 content here.
    </div>

    is_category('3')
    then display this data in the sidebar
    <div id="menu3">
    Menu 1 content here.
    </div>

    <?php endif; ?>

    Help requested:- So... can anyone offer a way to get this code into a working "tweak-able and paste-able" shape, please?

  2. jaks
    Member
    Posted 8 years ago #

    I'm currently looking for this same things. I have my categories setup with an ad include for each category but the posts in those categories have nothing.

Topic Closed

This topic has been closed to new replies.

About this Topic