Title: Sorting Post Loop By Votes
Last modified: May 23, 2017

---

# Sorting Post Loop By Votes

 *  Resolved [quicklyreviewus](https://wordpress.org/support/users/quicklyreviewus/)
 * (@quicklyreviewus)
 * [9 years ago](https://wordpress.org/support/topic/sorting-post-loop-by-votes/)
 * Is there a custom field I can use to sort the post loop by votes? In the below
   example ‘meta_key’ would be the custom field. Thanks.
 *     ```
       $posts = get_posts(array(
       	'post_type'			=> 'post',
       	'posts_per_page'	        => -1,
       	'meta_key'			=> 'votes',
       	'orderby'			=> 'meta_value',
       	'order'				=> 'DESC'
       ));
       ```
   

Viewing 1 replies (of 1 total)

 *  Plugin Author [aheadzen](https://wordpress.org/support/users/aheadzen/)
 * (@aheadzen)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/sorting-post-loop-by-votes/#post-9288600)
 * you can use do_shortcode(‘[voter_plugin_top_voted type=post num=5]’); if you 
   don’t want html, perhaps you could look into code for this shortcode and figure
   out what you want to achieve?

Viewing 1 replies (of 1 total)

The topic ‘Sorting Post Loop By Votes’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/voter-plugin_848b95.svg)
 * [Voter Plugin](https://wordpress.org/plugins/voter-plugin/)
 * [Support Threads](https://wordpress.org/support/plugin/voter-plugin/)
 * [Active Topics](https://wordpress.org/support/plugin/voter-plugin/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/voter-plugin/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/voter-plugin/reviews/)

## Tags

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

 * 1 reply
 * 2 participants
 * Last reply from: [aheadzen](https://wordpress.org/support/users/aheadzen/)
 * Last activity: [8 years, 11 months ago](https://wordpress.org/support/topic/sorting-post-loop-by-votes/#post-9288600)
 * Status: resolved