Hiding Posts in Website
-
Hi Guys,
I have a question that I really need help with. Ok so I have the following piece of code in my theme-functions.php file
function exclude_category($query) { if ( $query->is_home || $query->is_archive) { $query->set('cat', '-481'); } return $query; } add_filter('pre_get_posts', 'exclude_category'); ?>
What this code does is exclude or hide a post that is listed under the Product/Tech News section of our site. Now when I put it in everything works fine and theres no issues but if I create 5 posts under Tech/Product News and then click the Category name to show all the posts under that category it fails and just shows a blank page as if there is no posts under that category. How can i edit the above code to hide the posts in the site and search results etc. but not from the category view? I hope this makes sense.
[No bumping. If it’s that urgent, consider hiring someone.]
- The topic ‘Hiding Posts in Website’ is closed to new replies.