WordPress.org

Support

Support » How-To and Troubleshooting » script for sidebar.php, so sidebar changes when posts are viewed by category.

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

  • 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?

Viewing 1 replies (of 1 total)
  • 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.

Viewing 1 replies (of 1 total)
  • The topic ‘script for sidebar.php, so sidebar changes when posts are viewed by category.’ is closed to new replies.