title: Wordpress WP_Query $args, show published posts AND the current user's pending posts
body: <p>On my Wordpress website users can write their own posts on the group wall. I want to display all published posts on the group wall. I also want to display pending posts to the current user who is the author of these posts. Right now when the user submits a new post, there is no information displayed about it, they may not know if their post got submitted. I want to show them their pending post with the information that they need to wait for the post review.</p>
  <p>Is there a way to add the logic to the <code>$args</code> of the <code>WP_Query</code>? This is my code right now:</p>
  <pre><code>    //number of posts per page default
      $num =5;
      //page number
      $paged = $_POST['page'] + 1;
      
      $current_user = wp_get_current_user();
      $uid = $current_user-&gt;ID;
      
      //args
      $meta_query = array();
      $meta_query[] = array('key' =&gt; 'pm_accessible_groups','value' =&gt; sprintf(':&quot;%s&quot;;',1),'compare' =&gt; 'like');
      $args = array(
          'post_type' =&gt; 'pg_groupwalls',
          'post_status' =&gt; 'publish',
          'posts_per_page' =&gt;$num,
          'meta_query' =&gt; $meta_query,
          'paged'=&gt;$paged
      );
      
      
      
      //query
      $query = new WP_Query($args);
      //check
      if ($query-&gt;have_posts()):
          //loop
          while ($query-&gt;have_posts()): $query-&gt;the_post();
  
  </code></pre>
  <p>And later I have my template. This way it is only showing published posts as of now. I tried to find some information about it here: <a href="https://developer.wordpress.org/reference/classes/wp_query/" rel="nofollow noreferrer">https://developer.wordpress.org/reference/classes/wp_query/</a> , and later I tried changing the <code>$args</code> array to something like this:</p>
  <pre><code>
      //number of posts per page default
      $num =5;
      //page number
      $paged = $_POST['page'] + 1;
      
      $current_user = wp_get_current_user();
      $uid = $current_user-&gt;ID;
      
      //args
      $meta_query = array();
      $meta_query[] = array('key' =&gt; 'pm_accessible_groups','value' =&gt; sprintf(':&quot;%s&quot;;',1),'compare' =&gt; 'like');
      $args = array(
          'post_type' =&gt; 'pg_groupwalls',
          'post_status' =&gt; array (
               'relation' =&gt; 'AND',
               array(
                    'post_status' =&gt; 'publish',
               ),
               array(
                    'post_status' =&gt; 'pending',
                    'author' =&gt; $uid,
               ),
          ),
          'posts_per_page' =&gt;$num,
          'meta_query' =&gt; $meta_query,
          'paged'=&gt;$paged
      );
      
      
      
      //query
      $query = new WP_Query($args);
      //check
      if ($query-&gt;have_posts()):
          //loop
          while ($query-&gt;have_posts()): $query-&gt;the_post();
  
  </code></pre>
  <p>It is most probably not the way to do this, and obviously, it does not work the way I want. It shows both published and pending posts to all users (not just the current user who is an author). I could maybe create a new WP_Query, but this one is already paginated and showing 5 posts per page with a &quot;Load More&quot; button, I don't want to break the pagination.</p>
  <p>Is there a way to create this logic using <code>$args</code> array? Or any other way to achieve what I want?
  Thank you in advance.</p>
  <p>If there is more information needed or more of the code, I will try to update it.</p>