I’ve created a set of arguments for my WP_Query as to create an order of posts on my page, sorted by date:
$args = array( 'post_type' => 'position', 'post_status' => 'publish', 'orderby' => 'meta_value', 'meta_key' => 'end_date', 'order' => 'desc', 'author' => $current_user->ID, 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'is_active', 'value' => 'true' ) ) );
It works nicely, except for some of my posts the meta_key ‘end_date’ is not set, as to display an ongoing position, e.g.:
June 2017 - June 2018 February 2014 - July 2017 January 2018 - Now September 2018 - Now
My issue is, because the end_date is null, the posts are pushed to the bottom, where as I would like them in the top. It of course works if I change my order to ascending, but then the later end_date that isn’t null, will be in the bottom, while I still want to maintain the order of those elements as shown above.
Is there some kind of filter I can create to solve this?
- Huge resources deployed to find missing fighter jet
- New manufacturing orders post slower growth
- One pilot of missing fighter jet rescued
- Saigon Post Office tries new shades of yellow to fix controversial paint job
- Japan, ADB help VN improve use of water
- Hanoi’s four key infrastructure projects put into use
- Beauty queens shine at Miss Vietnam 2018 fashion show
- Government cracks down on imports of used machinery
- What value Vietnam’s heritage? An economist ponders
- The currency of experience has global value