- This topic has 10 replies, 2 voices, and was last updated 2 years, 11 months ago by
Tom.
-
AuthorPosts
-
November 20, 2019 at 3:37 pm #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?
Nanette
November 20, 2019 at 5:27 pm #1069414Tom
Lead DeveloperLead DeveloperHi there,
This looks ok – what’s changed since it was working?
One thing you can try is changing
is_Home()
tois_home()
.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 20, 2019 at 6:19 pm #1069465Nanette
I am not sure what changed. I can’t remember. To tell you the truth.
Nanette
November 21, 2019 at 9:09 am #1071015Tom
Lead DeveloperLead DeveloperWhat if you remove
&& $query->is_main_query()
?Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 21, 2019 at 9:34 am #1071093Nanette
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.
Nanette
December 12, 2019 at 4:59 pm #1102722Nanette
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.
Nanette
December 13, 2019 at 9:06 am #1103448Tom
Lead DeveloperLead DeveloperSo you’re using the exact same snippet on another website and it’s working?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 13, 2019 at 11:49 am #1103606Nanette
No on the same one but to exclude another category
Nanette
December 13, 2019 at 5:11 pm #1103773Tom
Lead DeveloperLead DeveloperCan you share both complete functions you’re using? Maybe they’re conflicting with each other.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 1, 2020 at 4:18 pm #1181746Nanette
I worked on the code and got it to work. Thanks for helping.
Nanette
March 2, 2020 at 12:11 am #1181906Tom
Lead DeveloperLead DeveloperNo problem 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.