Support » Fixing WordPress » Category Filter in wp-admin/edit.php does nothing

  • Resolved MarkRH

    (@markrh)


    Have WP 4.1 and using Twenty Twelve child them. In the admin section that shows all the posts, when I select a specific category and click filter nothing happens. It lists all the posts again.

    The Date drop-down does work to filter the list.

    First time I’ve noticed this.

Viewing 3 replies - 1 through 3 (of 3 total)
  • On my local site (on my PC) it also fails when using a different theme (the 2014 default) and with all plug-ins deactivated.

    I guess as a work-around I can either click on the Category link in the list or view the Categories directly and then click on the Count on the right side to list all the posts in that category. Still, the drop-down and filter button should work. Seems to be a bug.

    Figured it out. It was caused be the following in my theme’s functions.php file:

    function remove_my_categories( $wp_query ) {
    	$remove_cat = '-61,-74';
    
    	// remove from archives (except category archives), feeds, search, and home page
    	if( is_home() || is_feed() || is_search() || ( is_archive() && !is_category() )) {
       // if( is_home() || is_feed() || ( is_archive() && !is_category() )) {
    		set_query_var('cat', $remove_cat);
    	}
    }
    
    add_action('pre_get_posts', 'remove_my_categories' );

    I modified it to the following after noticing some other anomalies:

    function remove_my_categories( $wp_query ) {
    	$remove_cat = '-61,-74';
    
    	// remove from archives (except category archives), feeds, search, and home page
    	if( (is_home() || is_feed() || is_search() || ( is_archive() && !is_category() )) && !is_admin()) {
       // if( is_home() || is_feed() || ( is_archive() && !is_category() )) {
    		set_query_var('cat', $remove_cat);
    	}
    }
    
    add_action('pre_get_posts', 'remove_my_categories' );

    Apparently my theme’s function to exclude categories was affecting the admin’s post list as well which I did not expect. Adding the is_admin() exception solved it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Category Filter in wp-admin/edit.php does nothing’ is closed to new replies.