Adding exclude category function breaks the Theme
-
Hello!
I’m making preparations to migrate from the old theme to Twenty Twenty and found another issue.
I created a new child theme, and tried to put a typical function to functions.php file in order to exclude some categories from the loop.
/*Delete category from the loop*/ function exclude_category($query) { if ($query->is_home){ $query->set('cat','-37');} return $query; } add_filter('pre_get_posts','exclude_category');
This function worked just fine on my previous themes, but in the case of Twenty Twenty it returns a blank white screen and nothing more (in the front and admin panel).
Maybe there is an alternative way to exclude categories from the loop, especially if I try to use a static home page, and the main loop with posts on the subpage (ex. example.com/blog)?
Any ideas appreciated.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Adding exclude category function breaks the Theme’ is closed to new replies.