WordPress.org

Ready to get started?Download WordPress

Forums

Widget Logic
[resolved] Conditional tag doesn't work when I use "||" for multiple categories (4 posts)

  1. msolda1
    Member
    Posted 4 months ago #

    I am trying to hide a particular widget for all posts in 2 categories and show it on the rest. It works when I have the code for only one category:

    This works:

    !in_category('category1')

    Then when I try the following, it doesn't work. The widget still shows on both:

    !in_category('category1') || !in_category('category2')
    as well as
    !in_category('category1', 'category2')

    I also tried the following, and when I do this, it hides the widget completely everywhere
    !in_category('category1' || 'category2')

    Any suggestions?

    https://wordpress.org/plugins/widget-logic/

  2. charlie fasano
    Member
    Posted 4 months ago #

    I too am having this problem but with pages.

    this works:
    in_page('OAS Home')
    and
    in_homepage('')

    this does not work
    in_page('OAS Home') || in_page('Gallery') || in_page('Outreach')

    I also tried array:
    in_page(array('OAS Home','Gallery'.'Outreach'))

    Both of these give me errors posted at the top of the pages.

    Any suggestions please?

  3. charlie fasano
    Member
    Posted 4 months ago #

    I saw this on another post and tried it but it didn't work either:

    is_page('OAS_Homepage') && is_page('Gallery') && is_page('Members') && is_page('Outreach')

  4. charlie fasano
    Member
    Posted 4 months ago #

    FIXED!!!
    I don't know why, but this worked:

    is_page(array(249,19,737,OAS_Homepage))

    The numbers are the pages and since the designated homepage isn't given a number, I had to spell it out.

    Hope this helps.

Reply

You must log in to post.

About this Plugin

About this Topic