php - Order by custom field (numeric) in WP_Query -


i using following query posts post_type 'portfolio'.

$args = array(             'posts_per_page' => -1,             'offset'=> 0,            'post_type' => 'portfolio'          );  $all_posts = new wp_query($args); 

where $args is:

$args = array(                 'posts_per_page' => -1,                 'offset'=> 0,                'post_type' => 'portfolio',                'orderby' => 'up_count', //up_count numeric field posts table                'order' => desc              ); 

this should sort results up_count. that's not case. codex wp_query doesn't state sorting custom field (or may missing something?).

this query when debugging wp_query request.

select ap_posts.* ap_posts  1=1  , ap_posts.post_type = 'portfolio' , (ap_posts.post_status = 'publish' or ap_posts.post_status = 'private')  order ap_posts.post_date desc   

edit: up_count field of type int in table posts table.

p.s. using wordpress ver. 3.5.2

wp_query arguments should be:

$args = array(      'posts_per_page' => -1,      'offset'         => 0,         'post_type'      => 'portfolio',     'meta_key'       => 'up_count'     'orderby'        => 'meta_value_num'     'order'          => 'desc', ); 

all written in codex, need read many times understand.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -