- This topic has 1 reply, 2 voices, and was last updated 9 years, 1 month ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Select Page
Home › Forums › Community Support Forum › WordPress Plugins › Orbisius Child Theme Creator › Orderby parameter not working in WP_Query
Tagged: custom fields, orderby
I have a Mexin Child Theme and I’m trying to order posts by a custom field. I have done this for many other websites without any issues, but can’t get it to work with this child theme. I also can’t get a simple ascending order to work, it all seems to be overridden and posts of any kind sort by post date (descending). Here is my code:
$args = array(
‘post_type’ => ‘ocean-expeditions’,
‘orderby’ => ‘meta_value_num’,
‘meta_key’=> ‘year’
);
$the_query = new WP_Query($args);
?>
<div class=”ocean-exp-wrap headlines-wrap”>
<hr>
<?php endwhile; endif; ?>
</div>
I appreciate any and all help you can provide! Thanks!
Hi,
This is related to our plugin, however, you can find how to sort by meta value by going to this link:
http://wordpress.stackexchange.com/questions/15477/custom-query-with-orderby-meta-value-of-custom-field