WordPress.org

Ready to get started?Download WordPress

Forums

Adding sidebar widget only for certain categories (8 posts)

  1. GeoffCJ
    Member
    Posted 5 years ago #

    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.

    Any suggestions?

  2. macondo
    Member
    Posted 5 years ago #

    Hey GeoffCJ,

    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
    http://www.thaslayer.com/2008/10/16/wordpress-plugin-slayers-custom-widgets-v-10/

    Good luck!

  3. alanft
    Member
    Posted 5 years ago #

  4. GeoffCJ
    Member
    Posted 5 years ago #

    Alanft,

    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?

    Thanks,
    Geoff

  5. alanft
    Member
    Posted 5 years ago #

    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

  6. GeoffCJ
    Member
    Posted 5 years ago #

    Alanft,

    I had seen the codex page, but when I changed the logic code to in_category, the widget doesn't appear anywhere.

    Thanks,
    Geoff

  7. GeoffCJ
    Member
    Posted 5 years ago #

    This code:
    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.

    ???

    Geoff

  8. alanft
    Member
    Posted 5 years ago #

    you should check out the steps i mention in the FAQ. eg does it work in the default theme?

Topic Closed

This topic has been closed to new replies.

About this Topic