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 sidebaris_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?
- The topic ‘script for sidebar.php, so sidebar changes when posts are viewed by category.’ is closed to new replies.