WordPress.org

Ready to get started?Download WordPress

Forums

!!! Widget/sidebar element in category AND post? (2 posts)

  1. kjetilgf
    Member
    Posted 6 years ago #

    I'm really stuck on this:
    Is there some way I can make a widget (or hard-coded sidebar element) appear both in a specific category's sidebar AND in posts belonging to that category?
    I never assign more than one category to a post, so at least that should not be any problem.
    I can use Widget logic to make eg. a text widget appear in just one category, but then it won't show up in the posts (assigned to that category).
    Some line of code I can use? Ideas?
    Grateful for any hints!
    Kjetil

  2. kjetilgf
    Member
    Posted 6 years ago #

    SOLVED!
    I've asked about this seemingly impossible thing several times during the last weeks, and now Alan gave me an elegant solution.

    Basically install his Widget Logic plugin which gives you a php code field in each of your widgets.
    Here you insert the code that makes this widget appear where you like it - in my case:
    is_category('x') || (is_single() && in_category('x'))
    where x is the category's ID number.
    Done. Perfect.
    I'm using it to set up a big Italy site using WP as a CMS. The sidebars on different pages has to show relevant info for each Italian region. Each of the regions again are defined with its own category so I can post to each of them - and they're spread out on different Pages using a redirect plugin.
    Soon to be seen on dolcevita.no (now testing on dolcevita.no/wp)
    And a big thanks to Alan!
    Kjetil

Topic Closed

This topic has been closed to new replies.

About this Topic