WordPress.org

Support

Support » How-To and Troubleshooting » Dashboard – View Post By Category not sorting by category

Dashboard – View Post By Category not sorting by category

  • I have add this function to function.php to exclude a category from the front page and the archives:

    function exclude_category($query) {
    if ( $query->is_home || $query->is_archive) {
    $query->set('cat', '-10005');
    }
    return $query;
    }
    add_filter('pre_get_posts', 'exclude_category');

    But now in the dashboard when I try to view my posts by category they don’t sort properly. I know that the code above is affecting it because when I remove $query->is_archive code from function.php the sort post by category works properly in the dashboard.

    Also with that code above included in function.php the link does not work it just shows all the posts and I would have to manually type in a new url for it to sort properly.

    Example:
    The Url does not work with code implemented:
    http://stoppopculture.com/wp/wp-admin/edit.php?cat=10005

    But if I manually change it to:
    http://stoppopculture.com/wp/wp-admin/edit.php?category_name=pop

    It works with the code implemented.

    Thanks!

  • The topic ‘Dashboard – View Post By Category not sorting by category’ is closed to new replies.