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

Query Posts, order by meta value

Your query seems fine but there are couple of issues. Instead of your code (from wp_reset_query(); to wp_reset_query();) use following code and let us know what is the output. $new_args = array( ‘post_type’ => ‘datensatz’, ‘post_status’ => ‘draft’, ‘posts_per_page’ => -1, ‘meta_key’ => ‘completeness’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ); $my_new_query = new WP_Query( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)