I'm working on a custom taxonomy term page template where we want the items that are connected to the term sorted by a publication date (custom date field) - and if there are multiple items on the same day (formatted like YYYY-MM-DD) to then sort those by title, and finally sort by title if the custom field has not been filled out (older items).
So, I tried it hundred different ways with a WP_query and it does return most of the results as I want them - but in this case it's only returning the items that have the meta_key of publication_date. All other items are being ignored and not displayed. I tried a meta_query using a relation of "or" and compared the publication_date as EXISTS and NOT EXISTS, but that returned 0 results for me.
Also, the site is running 3.5.2 still and they do not want to upgrade.
Here is my most recent query that gets me the posts that have the publication_date custom field displayed in the correct order:
$term = get_queried_object(); // find the term of the taxonomy page we are on $wp_query = new WP_Query( array( 'post_type' => 'resource', 'tax_query' => array( array( 'taxonomy' => 'resource_types', 'field' => 'slug', 'terms' => $term->name, )), 'meta_key' => 'publication_date', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'paged' => $paged, 'posts_per_page' => '10', ));
I also tried using wpdb and running a SQL query, but I really am not sure how to accomplish what I want doing that. If someone could help me out that would be awesome!
Thanks in advance.