title: Get Posts including their Taxonomy with one query in Wordpress
body: <p>With </p>
  
  <pre><code>$posts = get_posts([
      'post_type' =&gt; 'post_foo',
  ]);
  </code></pre>
  
  <p>I can get all the posts, but it doesn't include the categories. Looping through the posts and retrieving the categories for each entry is bad for performance. </p>
  
  <p>Is there some way to get the posts data including categories with one query? Or which approach is the most efficient one?</p>
  
  <p>It would even help, if the <code>get_posts</code> would give the list of <code>term_id</code>s for a post. Then I could get all the categories from DB, then all the posts, and afterward merge the data. So 2 queries, instead of <code>1+n</code></p>
  
  <p>Thank you for your help.</p>