Support » How-To and Troubleshooting » Filter default widgets?

Filter default widgets?

  • I’m creating a theme with options where the user chooses a category to use on one page. I’d like that category to not show in feeds and, if they choose to use the default category widget it will be absent from this also.

    I’ve looked around for code for the feed exclude and found this which I can’t get to work in the theme’s functions.php:

    function exclude_category($query) {
    	if ( $query->is_feed ) {
    		$query->set('cat', '-21');
    return $query;
    add_filter('pre_get_posts', 'exclude_category');

    Is it possible to filter the default categories widget?

  • The topic ‘Filter default widgets?’ is closed to new replies.