WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I thought that this already works but now I tested it and it seems that it no longer works.
I have this code:

    'posts_per_page' => 3,
    'meta_key' => 'info_tab_1',
    'orderby' => 'meta_value_num',
    'order' => 'DESC'           
$info_tab = null;
$info_tab=new WP_Query( $args );

print_r($args); prints:

Array ( 
  [posts_per_page] => 3 
  [meta_key] => info_tab_1 
  [orderby] => meta_value_num 
  [order] => DESC 

print_r($info_tab); prints:

WP_Query Object ( 
  [query_vars] => Array ( 
    [posts_per_page] => 3 
    [meta_key] => info_tab_1 
    [orderby] => title 
    [order] => ASC 
    [error] => 
    [m] => 
    [p] => 0 ...
share|improve this question
you need to change 'orderby' => 'meta_value_num', to 'orderby' => 'meta_value', - orderby only accepts certain parameters – Howdy_McGee Dec 18 '13 at 20:50
@Howdy_McGee no difference. And in meta value info_tab_1 I have int values. – okonik Dec 18 '13 at 21:04
Cannot reproduce, I get meta_value_num correctly preserved in WP_Query using your snippet. Check for offending filters, etc. – Rarst Dec 18 '13 at 21:31
@Rarst What kind of filters? WP_Query for this block on this page every time returns order by title and order ASC. I meen that rand, date and etc orderby doesn't works. The same is about DESC/ASC order.. it returns every time ASC – okonik Dec 18 '13 at 21:41
Unfortunately there is ton of hooks in WP_Query where things can mess it up. You can use something like Query Monitor to look into it. – Rarst Dec 18 '13 at 21:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.