title: wp_query in shortcode not working as expected
body: <p>I created a simple shortcode</p>
  <pre><code>add_shortcode('lichthidau', 'hp_lich_thi_dau');
  function hp_lich_thi_dau( $atts ) {
  
  $output = '';
  extract( shortcode_atts( array( 'posttype' =&gt; 'lich' ), $atts) );
  $args = array( 
      'post_type' =&gt; $posttype,
      'post_status' =&gt; 'publish',
      'posts_per_page' =&gt; -1, 
      'orderby' =&gt; 'title',
      'order' =&gt; 'ASC',
   );
  $the_query = new WP_Query( $args );
  if ( $the_query-&gt;have_posts() ) {
      $itemprop = '';
  
      if ( 'microdata' === generate_get_schema_type() ) {
          $itemprop = ' itemprop=&quot;text&quot;';
      }
  
      echo '&lt;div class=&quot;bang-lich&quot;&gt;';
          
          //while ( $the_query-&gt;have_posts() ) {
              $output = $the_query-&gt;found_posts;
          //}
      echo '&lt;/div&gt;';
  }
  wp_reset_postdata();
  
  return $output;
  </code></pre>
  <p>}</p>
  <p>Then put it in Gutenberg shortcode block [lichthidau] in a page (ID = 106, for example).
  Without while loop, it's showing 2, which is the count of returning posts, and it's correct. However, if I enable while loop, it's taking the current page ID (106), and creating unlimited loops, while the expected result should be only two number 2.</p>
  <p>Can anyone advice why and how to fix, please?
  Thanks.</p>