Having Issue on Ordering CPT by Custom Field In Custom WP Query
Having a Custom Post Type loop like this, I am able to return the result on page BUT I am not able to set Order By of display using my own Custom Field.
As you can see here
$topic_number = get_post_custom_values($key = 'topic_order'); echo $topic_number;
I am able to get the value of Custom Field and echo it to page but the Order System not doing the job on ordering them. Can you please let me know how to fix this?
$args = array( 'tax_query' => array( array( 'taxonomy' => 'topic', 'field' => 'slug', 'terms' => 'movie', ), ), 'post_type' => 'essay', 'orderby' => 'topic_number', 'order' => 'DESC', ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); $topic_number = get_post_custom_values($key = 'topic_order'); echo $topic_number; print the_title() ."<br />"; the_excerpt(); endwhile;