Title: do I just paste the code in functions.php?
Last modified: August 19, 2016

---

# do I just paste the code in functions.php?

 *  [virgild](https://wordpress.org/support/users/virgild/)
 * (@virgild)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/do-i-just-paste-teh-code-in-functionsphp/)
 * I see a lot of tutorials like this,
 * [http://zeo.unic.net.my/exclude-category-in-wordpress/](http://zeo.unic.net.my/exclude-category-in-wordpress/)
 * that say to just paste a code anywhere in the funtions.php but when I do that
   the code either appears as body text on all my pages or a I get some scary error
 * My functions.php only has this
 *     ```
       <?php
        if ( function_exists('register_sidebar') )
        register_sidebar();
       ?>
       ```
   
 * and I’m trying to add this
 *     ```
       function exclude_category($query) {
       	if ( $query->is_feed ) {
       		$query->set('cat', '-5');
       	}
       return $query;
       }
   
       add_filter('pre_get_posts', 'exclude_category');
       ```
   
 * Please help! I must be doing something wrong..

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Micah Cooksey](https://wordpress.org/support/users/micahcooksey/)
 * (@micahcooksey)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/do-i-just-paste-teh-code-in-functionsphp/#post-1352846)
 * Are you putting it inside of the <?php and ?> tags? Your modified file should
   look like
 *     ```
       <?php
        if ( function_exists('register_sidebar') )
        register_sidebar();
   
       function exclude_category($query) {
       	if ( $query->is_feed ) {
       		$query->set('cat', '-5');
       	}
       return $query;
       }
   
       add_filter('pre_get_posts', 'exclude_category');
       ?>
       ```
   
 * Let me know if that helps!
 *  [magickman5](https://wordpress.org/support/users/magickman5/)
 * (@magickman5)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/do-i-just-paste-teh-code-in-functionsphp/#post-1352882)
 * hi virgild,
 * what micahcooksey is telling correct. can you specify what scary errors you are
   getting so that we can solve it…

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘do I just paste the code in functions.php?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [magickman5](https://wordpress.org/support/users/magickman5/)
 * Last activity: [16 years, 4 months ago](https://wordpress.org/support/topic/do-i-just-paste-teh-code-in-functionsphp/#post-1352882)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
