Uffo
Uffo

Reputation: 10046

Wordpress order asc by custom metabox not working

So here is my code:

$args1 = array( 'post_type' => 'artistsgallery','posts_per_page' => 1000, 'orderby'=>'meta_value_num', 'meta_key'=>'details_order', );
$loop1 = new WP_Query( $args1 );

In the custom metabox called details_order I store a number like: 1,2,3,4 the order that I want the posts to be displayed, but it's not working, it shows the last post first, and the newest post added it shows as first, I want them to be orderd by that metabox.

Upvotes: 0

Views: 1123

Answers (2)

Uffo
Uffo

Reputation: 10046

Ok, this is how I got it to work:

<?php
$args1 = array( 'post_type' => 'artistsgallery','posts_per_page' => 1000,'meta_key'=>'details_order','orderby'=>'meta_value_num','order' => 'ASC');
$loop1 = new WP_Query( $args1 );
?>

Upvotes: 1

Wyck
Wyck

Reputation: 2023

Did you try using the order parameter, 'orderby'=>'meta_value_num' 'order' => 'DESC'

If that doesn't work turn on debugging or dump the array out and see what is there.

Upvotes: 0

Related Questions