Title: Add Sorting Feature in shortcode.
Last modified: April 8, 2017

---

# Add Sorting Feature in shortcode.

 *  Resolved [Sourabh Agrawal](https://wordpress.org/support/users/sourabhasct/)
 * (@sourabhasct)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/add-sorting-feature-in-shortcode/)
 * Hi, I found that sorting feature was missing on this plugin.
    So, I have updated
   the code in my website to implement this feature Update the following file so
   we can use the shortcode with the sorting feature as well.
 * Location: \wp-team-showcase-and-slider\templates\wp_tsas-template.php
 *     ```
       <?php 
       if ( ! defined( 'ABSPATH' ) ) exit;
   
       function get_wp_tsas_showcase( $atts, $content = null ) {
              // setup the query
                   extract(shortcode_atts(array(
       		"limit" => '',	
       		"category" => '',		
       		"design" => '',
       		"grid" => '2',
       		"popup" => '',
       		"order" => '',
       		"order_by" => ''
   
       	), $atts));
   
       	if( $limit ) { 
       		$posts_per_page = $limit; 
       	} else {
       		$posts_per_page = '-1';
       	}
       	if( $category ) { 
       		$cat = $category; 
       	} else {
       		$cat = '';
       	}
   
       	if( $design ) { 
       		$teamdesign = $design; 
       	} else {
       		$teamdesign = 'design-1';
       	}	
   
       	if( $grid ) { 
       		$gridcol = $grid; 
       	} else {
       		$gridcol = '1';
       	}
       if( $popup ) { 
       		$teampopup = $popup; 
       	} else {
       		$teampopup = 'true';
       	}		
       if( $order ) { 
       		$teamorder = $order; 
       	} else {
       		$teamorder = 'date';
       	}		
       if( $order_by ) { 
       		$teamorder_by = $order_by; 
       	} else {
       		$teamorder_by = 'asc';
       	}		
   
       	$popup_html = '';
   
       	ob_start();
   
       	$post_type 		= 'team_showcase_post';
       	$orderby 		= 'post_date';
       	$order 			= 'DESC';
   
               $args = array ( 
                   'post_type'      => $post_type, 
                   'orderby'        => $orderby, 
                   'order'          => $order,
                   'posts_per_page' => $posts_per_page,  
                   'order' => $teamorder,  
                   'order_by' => $teamorder_by,  
   
                   );
       	if($cat != ""){
                   	$args['tax_query'] = array( array( 'taxonomy' => 'tsas-category', 'field' => 'term_id', 'terms' => $cat) );
                   }        
             $query = new WP_Query($args);
       	  global $post;
             $post_count = $query->post_count;
                 $count = 0;		 
       		  $i = 1;
       		if ( $query->have_posts() ) { ?> 
   
       		  <div class="wp-tsas-wrp">
       		  	<div class="wp_teamshowcase_grid <?php echo $teamdesign; ?>">
   
       			<?php  			 
   
                    while ( $query->have_posts() ) : $query->the_post();
   
                   	$popup_id = wp_tsas_get_unique();
                   	$count++;
   
                       $css_class="team-grid";
                       if ( ( is_numeric( $grid ) && ( $grid > 0 ) && ( 0 == ($count - 1) % $grid ) ) || 1 == $count ) { $css_class .= ' first'; }
                       if ( ( is_numeric( $grid ) && ( $grid > 0 ) && ( 0 == $count % $grid ) ) || $post_count == $count ) { $css_class .= ' last'; }
       				if ( is_numeric( $gridcol ) ) {					
       					if($gridcol == 1){
       						$per_row = 12;
       					}
       					else if($gridcol == 2){
       						$per_row = 6;
       					}
       					else if($gridcol == 3){
       						$per_row = 4;	
       					}
       					else if($gridcol == 4){
       						$per_row = 3;
       					}
       					 else{
                               $per_row = $gridcol;
                           }
       					$class = 'wp-tsas-medium-'.$per_row.' wp-tsas-columns';
       				}
   
       				switch ($teamdesign) {
       				 case "design-1":
       					include('designs/design-1.php');
       					break;
       				 case "design-2":
       					include('designs/design-2.php');
       					break;	
       				 default:					 
       						include('designs/design-1.php');
       					}		
   
       					if($teampopup == "true") {
       						ob_start();
       						include('popup/popup-design-1.php');
       						$popup_html .= ob_get_clean();
       					}
   
       			$i++;
                   endwhile; 
       			?>
       			</div><!-- end .wp_teamshowcase_grid -->
   
       			<?php echo $popup_html; // Print Popup HTML ?>
   
       		</div><!-- end .wp-tsas-wrp -->
       <?php	}
   
               wp_reset_query(); 
   
       		return ob_get_clean();	
       }
   
       add_shortcode('wp-team','get_wp_tsas_showcase');
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [anoopranawat](https://wordpress.org/support/users/anoopranawat/)
 * (@anoopranawat)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/add-sorting-feature-in-shortcode/#post-9013622)
 * Hi [@sourabhasct](https://wordpress.org/support/users/sourabhasct/),
 * Thanks for your suggestion.
 * At this time, Free plugin have only feature of sorting with date wise.
 * Thanks and Regards,
    WP Online Support
 *  Thread Starter [Sourabh Agrawal](https://wordpress.org/support/users/sourabhasct/)
 * (@sourabhasct)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/add-sorting-feature-in-shortcode/#post-9022106)
 * Ohke.. So, Is this feature available in the paid version?
 *  [anoopranawat](https://wordpress.org/support/users/anoopranawat/)
 * (@anoopranawat)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/add-sorting-feature-in-shortcode/#post-9025544)
 * Hello,
 *  Ya and many more feature in paid version.
 * Thanks & Regards
    WP Online Support
 *  [pasmer](https://wordpress.org/support/users/pasmer/)
 * (@pasmer)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/add-sorting-feature-in-shortcode/#post-9276795)
 * Dear [@sourabhasct](https://wordpress.org/support/users/sourabhasct/), how do
   you use the sorting in the shortcode?
    thanx PM

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Add Sorting Feature in shortcode.’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-team-showcase-and-slider_1f4463.
   svg)
 * [Team Slider and Team Grid Showcase plus Team Carousel](https://wordpress.org/plugins/wp-team-showcase-and-slider/)
 * [Support Threads](https://wordpress.org/support/plugin/wp-team-showcase-and-slider/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-team-showcase-and-slider/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-team-showcase-and-slider/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-team-showcase-and-slider/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [pasmer](https://wordpress.org/support/users/pasmer/)
 * Last activity: [8 years, 11 months ago](https://wordpress.org/support/topic/add-sorting-feature-in-shortcode/#post-9276795)
 * Status: resolved