WordPress.org

Ready to get started?Download WordPress

Forums

Widget Logic
Widget Logic is_category displaying on homepage (3 posts)

  1. jenniart
    Member
    Posted 1 year ago #

    I'm trying to display 2 sets of ads:
    1. Default ads (should appear everywhere except cat 2 & 3)
    2. Ads for category 2 & 3 pages and posts in either cat 2 or 3.

    This is what I have:

    Text:
    [Default AD CODE]

    Widget Logic:
    !is_category( array( 2, 3 ) ) && !in_category( array( 2, 3 ) )

    Text:
    [AD CODE for categories 2 & 3]

    Widget Logic:
    is_category( array( 2, 3 ) ) || in_category( array( 2, 3 ) )

    This is what's happening:
    The ads meant for categories 2 & 3 are showing up on the homepage, on the categories 2 & 3 pages, and on posts in categories 2 & 3. It's not supposed to show up on the homepage.

    The other ads meant for the rest of the site do show up on other category pages and posts pages that are not in category 2 or 3. They do not appear on the homepage.

    The weirdest thing about this problem is that sometimes it works... and sometimes it doesn't. Any ideas?

    Thank you.

    http://wordpress.org/extend/plugins/widget-logic/

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    sometimes it works... and sometimes it doesn't.

    possibly depends on which category the last post in the loop has (?)

    possibly integrate is_home() and/or is_single() into the conditional code.

  3. alanft
    Member
    Plugin Author

    Posted 1 year ago #

    yep, you need to combine in_category with is_single, as in_category is true when the first or last (depending on the theme) post in the loop is in the specd category

    It's mentioned in passing in a couple of points in the FAQ

    http://wordpress.org/extend/plugins/widget-logic/faq/

    eg

    is_category( array( 2, 3 ) ) || (is_single() && in_category( array( 2, 3 ) ) )

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic