Ordering Post by Meta Key (Not Working)


So I’ve read all the stack exchange posts on this, and I feel like what I have, based on what I’ve read, should be working. I’m a little confused as to why it isn’t.

$args = array(
    'post_type' => 'event',
    'meta_key' => 'events_startdate',
    'order_by' => 'meta_value',

  $post_query = new WP_Query($args);
  if($post_query->have_posts() ) {
    while($post_query->have_posts() ) {

I should mention that in my loop I have echo’d out my meta_key to make sure it’s returning the correct info:

<?php echo get_post_meta(get_the_ID(), 'events_startdate', true); ?>

And by my estimation it is. It’s spitting out a nice round number like this: 1545091200

This looks to me like it should work, but it doesn’t. Anyone see anything glaring that I’m missing?

Dale Spiteri 4 months 0 Answers 15 views 0

Leave an answer