WordPress.org

Forums

Filter default widgets? (1 post)

  1. aquabib
    Member
    Posted 5 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.