Created
June 25, 2012 13:01
-
-
Save Zenger/2988446 to your computer and use it in GitHub Desktop.
Wordpress select and order by a meta_value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$wQuery = new WP_Query( | |
array('post_type' => 'post', | |
'posts_per_page' => $how_many, | |
'cat' => '46,43', // categories should be supplied this way (an array doesn't work) | |
'meta_key' => 'post_views' , | |
'orderby' => 'meta_value_num', // or meta_value (if it's a string) | |
'order' => 'DESC') | |
); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment