WordPress.org

Ready to get started?Download WordPress

Forums

hide other users' posts in admin panel (1 post)

  1. TC.K
    Member
    Posted 2 years ago #

    Hi,
    I running a multi-author site, I don't want the posts from other authors to be shown in /wp-admin/edit.php page.

    I managed solve this problem by the codes from this thread:
    http://wordpress.org/support/topic/how-to-hide-other-users-posts-in-admin-panel-1

    The code is like this:

    function posts_for_current_author($query) {
    	global $pagenow;
    
    	if( 'edit.php' != $pagenow || !$query->is_admin )
    	    return $query;
    
    	if( !current_user_can( 'manage_options' ) ) {
    		global $user_ID;
    		$query->set('author', $user_ID );
    	}
    	return $query;
    }
    add_filter('pre_get_posts', 'posts_for_current_author');

    The codes work great, it hide the posts from other authors to be shown at here. But I do find another problem - the menu at top of the page doesn't change the associated number of posts by the author, it shows the number of all the post in my site.

    The menu I mean is like this:

    Mine () | All () | Published () | Draft () | Trash ()

    How to change the number in the () to reflect the number only associated to the author?

Topic Closed

This topic has been closed to new replies.

About this Topic