Order (by ASC) posts with meta_key so posts without values are last
Order (by ASC) posts with meta_key so posts without values are last
Order (by ASC) posts with meta_key so posts without values are last
I think the problem is that you have multiple meta values so your order by should be more targeted, like this. $args[‘orderby’] = array( ‘mp_exists’ => ‘ASC’, ‘mp_not_exists’ => ‘ASC’, ‘title’ => ‘ASC’ ); I don’t know by what meta you want to order so I added both of them, remove as necessary.
How to wp_query every Sunday between a startdate and enddate?
How to merge multiple foreach into 1 foreach and sort by date
I will start with this, never pass raw variables to a sql query! unless you have 100% control over the variable content, and even then I would still not pass it raw. Always use prepare(). Now going by your need you will need to do something like this <?php $paged = (get_query_var( ‘paged’)) ? get_query_var(‘paged’) … Read more
Customize the Sorting Dropdown in WooCommerce use another list or more page
How to combine meta_query and date_query with condition in WordPress
Sort custom post by custom field if none order by latest release
create a custom query for posts managed by Restrict Content Pro
So, I actually fixed the issue by reversing the order of the OR conditions. If anyone knows why this fixed it, I’d love to know. $next_event = get_posts( array( ‘post_type’ => ‘event’, ‘post_status’ => ‘publish’, ‘numberposts’ => 1, ‘fields’ => ‘ids’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘_post_date_year’, ‘value’ => $year, ‘compare’ … Read more