title: Shortcode for Wordpress
body: <p>I am trying to make a shortcode for Wordpress which will display specific posts based on the "id" of the post. </p>
  
  <p>I have found a shortcode example below which displays the most recent posts of "category1".</p>
  
  <p>Any thoughts on what should i do in order to make this work.</p>
  
  <pre><code>function pp_recent_work($atts, $content ) {
   extract(shortcode_atts(array(
      'limit'=&gt;'4',
      'title' =&gt; 'Recent Work',
      'orderby'=&gt; 'date',
      'order'=&gt; 'DESC',
      'filters' =&gt; '',
      'carousel' =&gt; 'yes'
      ), $atts));
      $output = '';
      if($filters){
          $filterstemparray = explode(',', $filters);
          if (count($filterstemparray)&gt;1) {
              $filtersarray = $filterstemparray;
  
          } else {
              $filtersarray = $filterstemparray[0];
          }
      };
      if($filters=="all" || empty($filters)) {
           $wp_query = new WP_Query(
              array(
                  'post_type' =&gt; array('portfolio'),
                  'showposts' =&gt; $limit,
                  'orderby' =&gt; $orderby,
                  'order' =&gt; $order
                  ));
      } else {
         $wp_query = new WP_Query(
          array(
              'post_type' =&gt; array('portfolio'),
              'showposts' =&gt; $limit,
              'orderby' =&gt; $orderby,
              'order' =&gt; $order,
              'tax_query' =&gt; array(
                  array(
                      'taxonomy' =&gt; 'filters',
                      'field' =&gt; 'slug',
                      'terms' =&gt; $filtersarray
                      )
                  ),
              )
              );
      }
  
      if ( $wp_query-&gt;have_posts() ):
      while( $wp_query-&gt;have_posts() ) : $wp_query-&gt;the_post();
  
          $id = $wp_query-&gt;post-&gt;ID;
          $type = get_post_meta($id, 'pp_pf_type', true);
          if($carousel == 'yes') { $output .= '&lt;li class="four columns"&gt;'; } else { $output .= '&lt;div class="four columns"&gt;';}
          $output .= '&lt;a href="'.get_permalink().'" class="portfolio-item"&gt;&lt;figure&gt;';
  
          $videothumbtype = ot_get_option('portfolio_videothumb');
              if($type == 'video' &amp;&amp; $videothumbtype == 'video') {
              global $wp_embed;
              $videolink = get_post_meta($id, 'incr_pfvideo_link', true);
              $post_embed = $wp_embed-&gt;run_shortcode('[embed  width="220" height="147"]'.$videolink.'[/embed]') ;
              $output .= '&lt;div class="picture recent_video"&gt;'.$post_embed.'&lt;/div&gt;';
          } else {
              if ( has_post_thumbnail()) {
                  $output .= get_the_post_thumbnail($wp_query-&gt;post-&gt;ID,'portfolio-thumb');
              }
          }
          $output .= '&lt;figcaption class="item-description"&gt;&lt;h5&gt;'.get_the_title().'&lt;/h5&gt;';
              $terms = get_the_terms( $wp_query-&gt;post-&gt;ID, 'filters' );
              if ( $terms &amp;&amp; ! is_wp_error( $terms ) ) : $output .= '&lt;span&gt;';
                  $filters = array();
                  $i = 0;
                  foreach ( $terms as $term ) {
                      $filters[] = $term-&gt;name;
                      if ($i++ &gt; 0) break;
                  }
                  $outputfilters = join( ", ", $filters ); $output .= $outputfilters;
              $output .= '&lt;/span&gt;';
              endif;
  }
  add_shortcode('recent_work', 'pp_recent_work');
  </code></pre>