Forums

[Plugin: Widget Logic] Show widget only on specific posts with tag/tags (4 posts)

  1. ruibo
    Member
    Posted 6 months ago #

    I'm looking to have a widget show only on posts with a specific tag or tags as well as the tag pages. When this widget shows, it should also replace the default widget that is there.

    Basically, what I'm trying to achieve is something to manage ads.

    I have a default ad placed for the whole site, but if the post/tag page relates to a specific tag, it'll replace that ad with a different ad.

  2. alanft
    Member
    Posted 6 months ago #

  3. ruibo
    Member
    Posted 6 months ago #

    yah i figured that part out, the has tag is doing the job ok but there's a little bug with it or i'm not utilizing it correctly.

    If you look here, http://test.gossipgamers.com/tag/playstation/ I have a widget that says HAS_TAG('PLAYSTATION') - basically only showing when theres a tag for playstation

    if you look here, http://test.gossipgamers.com/tag/xbox/, the xbox tag page says HAS_TAG('PLAYSTATION') is also showing up because the most recent post on that category has a playstation tag in it as well.

    if you look http://test.gossipgamers.com/tag/featured/, it the first post does not have playstation tag and thus is showing !HAS_TAG('PLAYSTATION') && !IS_HOME()

  4. alanft
    Member
    Posted 6 months ago #

    it's not a bug has_tag() will evaluate against the most recently processed post

    so if you want to narrow it down to single posts with a specific tag you need

    is_single() && has_tag(x)

    and so on

Reply

You must log in to post.

About this Topic