StudioPress Community Forums

StudioPress Community Forums (http://www.studiopress.com/support/index.php)
-   General Discussion (http://www.studiopress.com/support/forumdisplay.php?f=7)
-   -   Can a widget be restricted to one category? (http://www.studiopress.com/support/showthread.php?t=9773)

PogoFan 06-14-2009 10:17 AM

Can a widget be restricted to one category?
 
sandbox is http://aquaman.pogowasright.org It's a news site where each category is a news section.

I'm switching site over from geeklog to WP 2.7.1, and haven't figured out if there's a way that a widget can be restricted to one news category. For example, I'd like the news feed widget to only appear on the page when someone is looking at the news category, "Breaches," but not when they look at the home page or other news categories.

Is there a way to do that?

Debra 06-14-2009 10:52 AM

Re: Can a widget be restricted to one category?
 
try this http://wordpress.org/extend/plugins/widget-logic/

PogoFan 06-14-2009 11:22 AM

Re: Can a widget be restricted to one category?
 
Interesting plugin. Using the widget interface, I entered the logic code '!is_category(6)' in the logic code field because I only want the widget to appear in cat 6, but what that seems to do is display the widget in all categories except 6. Haven't figured out how to alter the code in widget_logic.php to address that or how to enter the code in the widget.

Aha -- just found the problem. For the benefit of anyone else who might want to use it: ignore the '!' that's in their example in the readme file. To just have the widget show up in one -- and only one -- category, the correct code to enter in the logic code field is 'is_category(6)' (or whatever category you want).

Thanks, Debra.

Debra 06-14-2009 11:32 AM

Re: Can a widget be restricted to one category?
 
did you put a return on the end

!is_category(6);

and ! means NOT so you are excluding it from cat 6

PogoFan 06-14-2009 11:34 AM

Re: Can a widget be restricted to one category?
 
Yeah.. found my error before I saw your reply. Thank you.


All times are GMT -5. The time now is 04:07 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.