Add a special filter link to All Posts in admin

First of all in your image you can see that WordPress lets you filter the posts by category, just bellow the what you have added to the image, But if you want to know how you can add your own link to the filter you can use the views_edit-post filter hook ex:

add_action('pre_get_posts', 'query_add_filter' );
function query_add_filter( $wp_query ) {
    if( is_admin()) {
        add_filter('views_edit-post', 'Add_My_filter');
    }
}

// add filter
function Add_My_filter($views) {
    global $wp_query;
    unset($views['mine']);
    $my_cat = YOUR-CAT-ID

    $query = array(
        'author'      => $current_user->ID,
        'post_type'   => 'post',
        'post_status' => 'publish',
    'cat'         => $my_cat
    );
    $result = new WP_Query($query);
    $class = ($wp_query->query_vars['cat'] == 'featured') ? ' class="current"' : '';
    $views['publish_f'] = sprintf(__('<a href="https://wordpress.stackexchange.com/questions/43831/%s"'. $class .'>Publish Featured <span class="count">(%d)</span></a>', 'publish featured'),
        admin_url('edit.php?post_status=publish&post_type=post&cat=".$my_cat),
        $result->found_posts);

    return $views;
}

just make sure you change YOUR-CAT-ID to the actual category id

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)