Using WP meta query to show custom post types by a start and finish date

The query will by default GROUP BY the post ID, meaning that a post will only appear once in the list. You can remove that GROUP BY pretty easily with a filter: add_filter(‘posts_groupby’,’__return_empty_string’); $events = new WP_Query($args); remove_filter(‘posts_groupby’,’__return_empty_string’); That might get you what you want. It is a bit hard to tell. Without the GROUP … Read more

Ordering custom posts by meta field date

You are not querying/saving the correct meta_key. For example, looking at your code, you pass $typename variable to update_post_meta() as meta_key and $typename=”events”. But later in the query you are querying for meta_key = date. Also, you pass $meta as meta_value and in your actual code $meta is an array containing multiple values (location, date, … Read more

How to get current page nearest parent id?

try this. global $post; // if outside the loop $page_object = get_queried_object(); $page_id = get_queried_object_id(); // Get current page id $args = array( ‘sort_order’ => ‘ASC’, ‘sort_column’ => ‘post_title’, ‘hierarchical’ => 1, ‘exclude’ => ”, ‘include’ => $page_id, ‘meta_key’ => ”, ‘meta_value’ => ”, ‘authors’ => ”, ‘child_of’ => 0, ‘parent’ => -1, ‘exclude_tree’ => … Read more

Sorting by meta_key different to search criteria?

The value for the value key in the meta query is probably the cause of the problem. ‘value’ => get_post_meta( get_the_ID(), ‘cancelled’, true ) The get_post_meta call actually retrieves the value of the meta key “cancelled” for the current post. So, in your current WP_Query, you’re retrieving all posts with a paypal_recur_profile_status equal to the … Read more