title: How to create shortcode to display all posts in each category
body: <p>I have this problem: i have made a custom page with his own set of categories. In a shortcode i want to get all the categories and in the categories i want all the post related to that category.</p>
  
  <pre><code>function innovatiewerkplaats_sort($atts, $content = null){
  
      global $post;
  
      $terms = get_terms('innovatiewerkplaats_categories'); // Get all terms of a taxonomy
  
      $nieuws = '';
  
      foreach($terms as $term):
          $nieuws .= '&lt;div class="one"&gt;
                          &lt;h2&gt;Thema &lt;strong&gt;'.$term-&gt;name.' id='.$term-&gt;term_id.'&lt;/strong&gt;&lt;/h2&gt;
                      &lt;div class="wrapper"&gt;';
  
          $category_query_args = array(
              'post_type' =&gt; 'innovatiewerkplaats',
              // 'category' =&gt; $term-&gt;term_id,
              'category_name' =&gt; $term-&gt;name,
              // 'cat'  =&gt; $term-&gt;term_id,
          );
  
          query_posts($category_query_args);
  
          if( have_posts() ) : while (have_posts()) : the_post();
  
              $post_home= get_the_post_thumbnail( $page-&gt;ID, 'post-home');
              $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post-&gt;ID), '' );
              $url = $thumb['0'];
              $excerpt = get_the_content();
              $excerpta = preg_replace("~(?:\[/?)[^/\]]+/?\]~s", '', $excerpt);
  
              // $ter = wp_trim_words( apply_filters( 'rpwe_excerpt', $excerpta ), $args['length'], '…' );
              $nieuws .= '&lt;a href="'.get_permalink().'" title="'.get_the_title().'" class="one_fourth workplace"&gt;'.$term-&gt;term_id.'&lt;span class="img" style="background:url('.$url.') no-repeat center center; background-size:cover;"&gt;&lt;/span&gt;&lt;span class="titel"&gt;'.get_the_title().'&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;span class="more"&gt;Lees meer&lt;/span&gt;&lt;/a&gt;';
  
          endwhile; endif;
  
          $nieuws .='&lt;/div&gt;&lt;/div&gt;';
  
      endforeach;
  
      return $nieuws;
  }
  </code></pre>