I try to order a WP_Query of a custom post type 'entry' by a meta value 'votes', but it keeps showing up ordered by date. My code:
$args = array( 'post_type' => 'entry', 'orderby' => 'votes', 'order' => 'DESC', 'posts_per_page' => 10, 'post_status' => 'publish' ); $loop = new WP_Query($args);
When I evaluate
$loop->request in xDebug, I get this, which indicates the results are indeed ordered by
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'entry' AND ((wp_posts.post_status = 'publish')) ORDER BY wp_posts.post_date DESC LIMIT 0, 10
Do I need to use
meta_query to order on custom post type meta fields? I thought that was only needed when you want to compare/restrict results based on custom meta?