Custom query, checking values of multiple meta keys

You can use meta_query to combine multiple queries using either AND or OR relation. Granted, it does get a bit complex in this case, but because you can nest multiple queries, you can still achieve it. This is covered in the WP_Meta_Query documentation and also to an extent in the WP_Query docs. Here’s what I … Read more

Help ordering Post loop by two meta values

If you’re using WordPress 4.2 or newer then you can do the following: $args = array( ‘post_type’ => ‘events’, ‘posts_per_page’ => 10, ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘start_date_clause’ => array( ‘key’ => ‘start_date’, ‘compare’ => ‘EXISTS’, ), ‘ticket_status_order_clause’ => array( ‘key’ => ‘ticket_status_order’, ‘compare’ => ‘EXISTS’, ), ), ‘order_by’ => array( ‘start_date_clause’ => ‘ASC’, … Read more

Get posts with same meta value as current post

You should first get the meta value for the current post, then use it to make another query. global $authordata, $post; $my_meta = get_post_meta( $id, ‘stashkey’, true); $authors_posts = get_posts( array( ‘author’ => $authordata->ID, ‘post_parent’ => 0, ‘orderby’ => ‘menu_order’, ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘stashkey’, ‘value’ => … Read more

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