Support » Fixing WordPress » do I just paste the code in functions.php?

  • I see a lot of tutorials like this,

    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)
  • 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!

    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.