Adding sidebar widget only for certain categories
I have a personal site, based in wordpress, that I post on a variety of topics. For one topic, I also run a NING site on the same topic.
I’d like to figure out a way, where for my WordPress site, I can have a widget appear in the sidebar to “advertise” the NING site, but only for posts in one category.
I stumbled upon your message while looking for the exact same thing you are looking for, namely the ability to display widgets only at certain conditions.
I think I found a solution here:
Slayer’s Custom Widgets v1.0
by me 🙂
Thanks. Hopefully you’ll see this, but I installed your plug-in and I’m still having trouble getting the logic to work.
If you look at my site, http://kimandgeoff.com , I’ve got a Category “Kayak”. I installed your widget, and used the logic is_category(Kayak) to display a link to my Ning site. It shows up when you click on the category Kayak, and not elsewhere, so I’m partway there.
I’m trying to write the logic statement to make it appear there, or in the sidebar for any post that is in category Kayak, and can’t get that to work. Any hints?
it’s the difference between in_category and is_category
read about the difference on http://codex.wordpress.org/Conditional_Tags
and you’ll find people doing the same thing in these posts http://wordpress.org/tags/widget-logic
i’ll probably add something about this in the FAQ or ‘other notes’ section soon
I had seen the codex page, but when I changed the logic code to in_category, the widget doesn’t appear anywhere.
is_category(kayak) || (is_single() && in_category(kayak))
Seems like it would do what I want, but it doesn’t. I get the widget displayed if I click on the category Kayak, but a single post within that category doesn’t have the widget.
- The topic ‘Adding sidebar widget only for certain categories’ is closed to new replies.