Title: Hiding Posts in Website
Last modified: August 21, 2016

---

# Hiding Posts in Website

 *  Resolved [irishpeck](https://wordpress.org/support/users/irishpeck/)
 * (@irishpeck)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/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](http://codex.wordpress.org/Forum_Welcome#No_Bumping). If it’s 
   that urgent, consider [hiring someone](http://jobs.wordpress.net/).]_

Viewing 1 replies (of 1 total)

 *  Thread Starter [irishpeck](https://wordpress.org/support/users/irishpeck/)
 * (@irishpeck)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/hiding-posts-in-website/#post-3789477)
 * Found a fix just in case other people had the same problem and that is to remove
   this line of code
 * || $query->is_archive

Viewing 1 replies (of 1 total)

The topic ‘Hiding Posts in Website’ is closed to new replies.

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [exclude](https://wordpress.org/support/topic-tag/exclude/)
 * [hidden](https://wordpress.org/support/topic-tag/hidden/)
 * [hide](https://wordpress.org/support/topic-tag/hide/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)

 * 1 reply
 * 1 participant
 * Last reply from: [irishpeck](https://wordpress.org/support/users/irishpeck/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/hiding-posts-in-website/#post-3789477)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
