WP Query. Ordering posts by another post types meta
WP Query. Ordering posts by another post types meta
WP Query. Ordering posts by another post types meta
Why does this incorrect pre_get_posts meta_query work for sort order?
Is there any way to get all custom posts and all custom terms with it’s meta in few queries?
This is the answer to my question: $args = array( ‘post_type’ => ‘myType’, ‘post_per_page’ => $number, ‘showposts’ => $number, ‘meta_query’ => array( array( ‘key’ => ‘month’, ‘value’ => array(date(“F”),date(“F”, strtotime(‘+1 month’))), ‘compare’ => ‘IN’ ), array( ‘key’ => ‘day’, ‘value’ => date(“j”), ‘compare’ => ‘>=’ ), array( ‘key’ => ‘year’, ‘value’ => date(“Y”), ‘compare’ => … Read more
Finally I’ve decided to use custom sql query with get_results method. $query = “SELECT SQL_CALC_FOUND_ROWS p.*, IFNULL(m2.meta_value, p.post_date_gmt) as zen_date FROM {$wpdb->posts} p LEFT JOIN {$wpdb->postmeta} m1 ON (p.ID = m1.post_id AND m1.meta_key = ‘is-exclude’) LEFT JOIN {$wpdb->postmeta} m2 ON (p.ID = m2.post_id AND m2.meta_key = ‘is-push’) WHERE p.post_type=”post” AND p.post_status=”publish” AND m1.post_id IS NULL … Read more
Sorting with meta_query and multiple, optional meta keys
How to filter on placeholder image
I would advice you to store the time as a string instead of a d-m-Y format. Use strtotime() to format it as a long integer. This will help you comparing the strings. I’m not 100% sure if PHP is able to compare string dates. It is however able to compare timetamps as this user mentioned … Read more
I have the code below (started from yours) setup as a shortcode and it works fine. When I change the direction ‘ASC’ to ‘DESC’, the sort order changes as well, so it is not ‘luck’ that posts are in the correct order. It assumes that the dates are stored yyyymmdd. NOTE that one must remove … Read more
wordpress meta query with multiple meta condition causing a load on server and slows down the server..!