Title: Custom Sort Code
Last modified: August 21, 2016

---

# Custom Sort Code

 *  [michaeljmac](https://wordpress.org/support/users/michaeljmac/)
 * (@michaeljmac)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/custom-sort-code/)
 * I am trying to find out where I would place the array of parameters for a custom
   sort.
 * Right now I have I short code that displays a list of posts:
 *     ```
       $q = new WP_Query ( array('meta_key' => '_count-views_all', 'orderby' => 'meta_value_num' , 'posts_per_page' => '20', 'order' => 'DESC') );
   
       	$list = '<ul class="recent-posts">';
   
       	while ($q->have_posts()) : $q->the_post();
   
       		$list .= '<li>' . get_the_date() . '<a href="' . get_permalink() . '">' . get_the_title() . '</a>' . '<br />' . get_the_excerpt() . '</li>';
   
       	endwhile;
   
       	wp_reset_query();
   
       	return $list . '</ul>';
       ```
   
 * , but I would prefer to have this formatted like the theme. So, I want to place
   the it within the theme query instead of its own query like this.
 * Thanks!

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

 *  Thread Starter [michaeljmac](https://wordpress.org/support/users/michaeljmac/)
 * (@michaeljmac)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/custom-sort-code/#post-4180563)
 * Just as a note, I tried to do a simple url insertion, but it didn’t work and 
   just continues to sort by date.
 * `?meta_key=_count-views_all&orderby=meta_value_num&order=DESC`
 * Thanks again!
 *  [andysysadmin](https://wordpress.org/support/users/andysysadmin/)
 * (@andysysadmin)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/custom-sort-code/#post-4180757)
 * Where should I put the sort codes the sort codes to change the menu of mio theme…
   actually I want to change the menu/page colors …. is it possible…………
 *  [andysysadmin](https://wordpress.org/support/users/andysysadmin/)
 * (@andysysadmin)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/custom-sort-code/#post-4180760)
 * Can I use shortcodes or anything to change the menu colors of the menu/other 
   part..

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

The topic ‘Custom Sort Code’ is closed to new replies.

## Tags

 * [post](https://wordpress.org/support/topic-tag/post/)
 * [sort](https://wordpress.org/support/topic-tag/sort/)

 * 3 replies
 * 2 participants
 * Last reply from: [andysysadmin](https://wordpress.org/support/users/andysysadmin/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/custom-sort-code/#post-4180760)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
