Home Forums Support my post

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1069323
    Nanette

    I altered the Merch theme for my knowledge based website
    I changed the Merch blog home page (https://gpsites.co/merch/blog/) to (https://nir-for-food.com/industries/)
    The page uses WSP and I used PHP snippets to exclude categories I did not want to be pulled to the page
    They were both working for a while but now one exclusion PHP for one category is not working.
    I don’t know why.
    The PHP code is the following:
    function exclude_Applications( $query ) {
    if ( $query->is_Home() && $query->is_main_query() ) {
    $query->set( ‘cat’, ‘-26’ );
    }
    }
    add_action( ‘pre_get_posts’, ‘exclude_Applications’ );

    I am trying to exclude the category applications and wondered why the PHP code above use to work but now doesn’t?

    #1069414
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    This looks ok – what’s changed since it was working?

    One thing you can try is changing is_Home() to is_home().

    #1069465
    Nanette

    I am not sure what changed. I can’t remember. To tell you the truth.

    #1071015
    Tom
    Lead Developer
    Lead Developer

    What if you remove && $query->is_main_query()?

    #1071093
    Nanette

    I remember what changed, I had only the industry category posts which were 7. Now I have the category application posts showing up which I don’t want.

    I will try your suggestions one at a time to see what it does.

    #1102722
    Nanette

    I tried your suggestions but it won’t work. I have the exact PHP snippet to exclude another category and it is working. However, this one just won’t work. I can’t figure out why it won’t.

    #1103448
    Tom
    Lead Developer
    Lead Developer

    So you’re using the exact same snippet on another website and it’s working?

    #1103606
    Nanette

    No on the same one but to exclude another category

    #1103773
    Tom
    Lead Developer
    Lead Developer

    Can you share both complete functions you’re using? Maybe they’re conflicting with each other.

    #1181746
    Nanette

    I worked on the code and got it to work. Thanks for helping.

    #1181906
    Tom
    Lead Developer
    Lead Developer

    No problem 🙂

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.