Is it possible to sort the post based on a custom field?

Is it possible to sort the post based on a custom field?

I have a custom field called “value_date” where I enter a date e.g 20/04/2017

<?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'value_date', true);
wp_reset_query();
?>

The idea is sort the upcoming dates first in the loop, is possible?

Read more here: Is it possible to sort the post based on a custom field?

Leave a Reply

Your email address will not be published. Required fields are marked *