WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to modify posts listing at back end?

Say, for a particular user, with role author, O want to list only few posts at posts listing. How can I do this?

share|improve this question
Are you asking to filter the posts by author? – Nicole Dec 16 '11 at 14:59
Nope. I was to list only few posts when any particular user is loggedin, on back end post listing – I-M-JM Dec 16 '11 at 15:30
Yes it's possible using some filters available. But you might have to build your own displays for this role, because if you use the current capabilities provided in WP, then other posts will be visible (not editable) to the user logged in with a custom role. Are you interested in knowing how? – Rutwick Gangurde Dec 19 '11 at 3:23
@ Rutwick Gangurde yes – I-M-JM Dec 20 '11 at 5:04
Cool... You have the answer below! – Rutwick Gangurde Dec 21 '11 at 18:21

You can do this easily using the edit_posts_per_page hook or edit_{$post_type}_per_page hook for pages and custom post types

You can change based on the user role:

function my_edit_post_per_page_role_based( $per_page, $post_type ) {
    //admin sees 25 posts per page
    if (current_user_can('administrator')){return 25;}
    //editor sees 20 posts per page
    elseif(current_user_can('editor')){return 15;}
    //author sees 10 posts per page
    elseif(current_user_can('author')){return 10;}
    //contributor sees 5 posts per page
    elseif(current_user_can('contributor')){return 5;}
    return $per_page;

add_filter( 'edit_posts_per_page', 'my_edit_post_per_page_role_based' );

Or change base on user id:

function my_edit_post_per_page_user_based( $per_page, $post_type ) {
    global $current_user;
    //specific user id ex: user with the ID of 23
    if (23 == $current_user->ID){
        return 20;
    //user group
    $can_see_only_10 = array(2,5,36,55,47); //array holding the group ids
    if (in_array($current_user->ID,$can_see_only_10)){
        return 10;

    return $per_page;

add_filter( 'edit_posts_per_page', 'my_edit_post_per_page_user_based' );
share|improve this answer
based on example 2 that you provided, will it also restrict user to edit only those posts mentioned in array $can_see_only_10? – I-M-JM Dec 26 '11 at 11:02
@I-M-JM: not at all, its not restricing any thing , just setting the number of posts the user can see per page on the admin post listing. – Bainternet Dec 26 '11 at 12:04
you didn't understood my question at all – I-M-JM Dec 28 '11 at 4:25
that's the only thing anyone can understand from the question. – Bainternet Dec 28 '11 at 10:36

Your Answer


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.