Site logo

Archived topic

my post

10 replies · Started by Nanette on November 20, 2019

Viewing posts 1–11 of 11

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?

Hi there,

This looks ok - what's changed since it was working?

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

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

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

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.

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.

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

No on the same one but to exclude another category

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

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

No problem :)

This archived topic is closed to new replies.