Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a featured posts slider on my site's front page. It displays n posts (5 right now) from the category featured. If I have 5 posts in that category, and publish a 6th, the oldest of the 6 doesn't show up in the slider or below in the list of all recent posts. My solution right now is to go to All Posts > Published > Featured, pick one to un-feature, and go on with my life.

I'll take suggestions on a better solution (fix the featured slider is probably a decent response), but what I'm looking for here is a way to add a link to All Posts that will show me all published featured posts.

enter image description here

share|improve this question
    
Hint: That's bulk_actions –  kaiser Feb 28 '12 at 17:41
add comment

1 Answer

up vote 5 down vote accepted

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="%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

share|improve this answer
    
Just to clarify, my current process is: load all posts, load all published posts, filter by featured category. I'm just trying to cut down on loads. Thanks for this answer, I'll play with this tonight and get back to you. –  hookedonwinter Feb 28 '12 at 19:54
    
Well it makes more sense now that you clarified :) let me know how it works. –  Bainternet Feb 28 '12 at 21:21
    
I'm finally getting to this.. Where would this hook go? wp-admin/includes/admin.php? Or some other location? –  hookedonwinter Mar 8 '12 at 20:34
    
That worked. I made a plugin for it. Thank you so much! –  hookedonwinter Mar 8 '12 at 21:03
    
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.