Advertisement
miriamdepaula

WordPress: Posts for current author

Feb 23rd, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. <?php
  2. //exibe somente os posts do usuario atual no admin - show only current author's posts
  3.  
  4. function posts_for_current_author($query) {
  5.         global $pagenow;
  6.     if( 'edit.php' != $pagenow || !$query->is_admin )
  7.         return $query;
  8.     if( !current_user_can( 'manage_options' ) ) {
  9.        global $user_ID;
  10.        $query->set('author', $user_ID );
  11.      }
  12.      return $query;
  13. }
  14. add_filter('pre_get_posts', 'posts_for_current_author');
  15.  
  16. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement