title: showing only posts from current user - Custom post - Wordpress
body: <p>I want to show posts ( under a custom post type ) only posted by the current logged in user.I have used this code for <code>reservation</code> and <code>listings</code></p>
  
  <h2>Below here is the code</h2>
  
  <pre><code>add_filter( 'parse_query', 'pre_order_posts_filter' );
  
  function pre_order_posts_filter( $query ) {
  
      global $post_type;      
  
      if(is_admin()){
          $current_user = wp_get_current_user();
          if ( 'reservation' == $post_type ) {
              if ( in_array( 'shop_manager', $current_user-&gt;roles ) ) {
                  $query-&gt;query_vars['meta_key'] = 'author_id';
                  $query-&gt;query_vars['meta_value'] = $current_user-&gt;ID; 
                  $query-&gt;query_vars['post_status'] = array('pending', 'publish');     
              }
  
          }
          elseif ( 'listings' == $post_type ) {
  
              if ( in_array( 'shop_manager', $current_user-&gt;roles ) ) {
                  $query-&gt;query_vars['post_author'] = $current_user-&gt;ID;     
              }
  
          }
      }
  
  }
  </code></pre>
  
  <p>Its working for <code>reservation</code> but not for <code>listings</code>.</p>