• Currently I am sorting my posts based on custom_field (that is a number).

    However, If I have a posts that have numbers 3 and 12, then the code below sorts is 12,3. How do I sort by number?

    I read you can do it bu using ORDER BY ABS, but I dont know how to implement it in my code below.

    global $paged;
    $curpage = $paged ? $paged : 1;
    $args = array('post_type' => 'biznese',
            'paged' => $curpage,
      	'meta_query' => $metaquery,
    	'posts_per_page' => 12,
    	'meta_key'=>'renditja',
     	'orderby' => 'meta_value',
    	'order' => 'asc'
    );
Viewing 1 replies (of 1 total)
  • Thread Starter korabd

    (@korabd)

    nevermind, I found it

    just need to change

    'orderby' => 'meta_value',

    to

    'orderby' => 'meta_value_num',

Viewing 1 replies (of 1 total)
  • The topic ‘Order by ABS’ is closed to new replies.