different sidebar based off category
-
Hi,
What I want to accomplish is, I want a different sidebar.php file to be displayed based off the category that is selected. I know I’d have to create a sidebar file for each category, but how do I go about coding it to be displayed based off category?
I have somewhere around 100 categories that I need to do.
Thanks,
Jack
-
Conditional_Tags – should have all the info you need.
hi thanks.
<?php if (is_category('5') ) { include ('prisonbreakphoto.php'); }elseif (is_category('6') ) { include ('ghostwhispererpics.php'); }else{ include ('blankpics.php'); } ?>Here is my code, but it’s not displaying any includes except the blankpics one. I’m in category 5, and it displays the blankpics, not the prisonbreakphoto.php file, how do i fix this?
Try this example:
http://ww.wp.xz.cn/support/topic/157451?replies=14#post-696191thank you.
hmm interesting enough. The following code will not display the }else{ statment.
<?php if (is_page('2759'|| '2785' || '2788' || '2792') ) { include(TEMPLATEPATH . '/sidebar/ghostwhispererside.php'); }else{ include(TEMPLATEPATH . '/sidebar.php'); } ?>It won’t display the sidebar for any other page but the first (ghostwhispererside.php) on every page. any clue what im missing?
Check with the conditional tags page again, you need to use array with is_page and get rid of the ||.
That doesn’t work. Which is the reason why || was added. It was working properly but stopped working once I upgraded. Now doing it the way the conditional tags says does not work.
<?php if (is_page(array ('2759','2785','2788','2792') ) { include(TEMPLATEPATH . '/sidebar/ghostwhispererside.php'); }else{ include(TEMPLATEPATH . '/sidebar.php'); } ?>Returns the error of:
Parse error: syntax error, unexpected '{' in /home/camvixsi/public_html/thetvstop/wp-content/themes/thetvstop/pageside.php on line 4Line 4 is: if (is_page(array (‘2759′,’2785′,’2788′,’2792’) ) {
`
You need another ) in the following:
if (is_page(array ('2759','2785','2788','2792') ) {What you posted is exactly what I posted? it returns the same error.
What you posted is exactly what I posted? it returns the same error.
Yes, I just reposted your code that needs fixing. All parenthesis must be paired, and yours were not. Here is the fixed bit of code (note the added parenthesis):
if (is_page(array ('2759','2785','2788','2792'))) {Is there any way to do this from admin panel.ie. without manual intervention.
Suppose a blog has more than 100 categories and wants different sidebar for different categories.
Then is it possible to have widgetized sidebars for each categories from admin panel??
is there any pluginhttp://ww.wp.xz.cn/extend/plugins/widget-logic/ allows you some control over widgets.
The topic ‘different sidebar based off category’ is closed to new replies.