Exclude Category posts and Sidebar widget problem
-
Hope someone can help with this.
I have successfully added the code to exclude the posts from one category from the home and archive page but I do want to show the posts from that category in a sidebar widget. However, the code I’m using is excluding the posts from the sidebar widget as well so it appears to be empty.
The code is in the functions.php
function exclude_category($query) { if ( $query->is_home || $query->is_archive) { $query->set('cat', '-6'); } return $query; } add_filter('pre_get_posts', 'exclude_category');
Any help with this appreciated, thanks.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Exclude Category posts and Sidebar widget problem’ is closed to new replies.