Widget Logic
[resolved] exclude from category -both category landing and single posts (3 posts)

  1. streettb
    Posted 3 years ago #

    I need some help with the correct logic...I'm trying to have a widget appear across my blog EXCEPT for in a category (the widget should NOT appear in both the category landing page and single posts of that category).

    This logic is not working:

    !( is_single() && in_category ('how-to-not-look-like-a-freshman')) || !is_category ('how-to-not-look-like-a-freshman')

    The widget is not appearing on the category landing page (which I want), but is showing on the single posts in the category...

    how do I properly form !( is_single() && in_category ('how-to-not-look-like-a-freshman')) so that the widget won't appear in the single posts of the category?


  2. alanft
    Plugin Author

    Posted 3 years ago #

    the opposite of that, to make it appear on a category page or single posts is in the FAQ as

    is_category(X) || (is_single() && in_category(X))

    so reverse that with !( … ) around it like this…

    !( is_category(X) || (is_single() && in_category(X)) )

  3. streettb
    Posted 3 years ago #

    Yes, that logic works - many thanks for your quick reply!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic