Query 3 meta_key and orderby

The meta_query has to be an array of array to manage the relation between the meta queried. You can read more on the codex page about wp_query here In an other side, post_type, post_status, has nothing to do on your meta_query clause, they are already in the main arguments if the query.

WP Query works outside a function, not inside a function

functions return an output. you don’t want to just echo it out. try this as your function: function mycoolquery() { $custom_taxterms = wp_get_object_terms( $post->ID, ‘region’, array(‘fields’ => ‘ids’) ); // arguments $args = array( ‘post_type’ => ‘stay’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 25, // you may edit this number ‘orderby’ => ‘rand’, ‘tax_query’ => array( … Read more

Get post related to current post

From what i understand of your question, you are trying to do a meta query. You can do this by the following arguments: $args = array( ‘posts_per_page’ => 10, ‘post_type’ => ‘mobile’, ‘meta_query’ => array( array( ‘key’ => ‘select2_posts’, ‘compare’ => ‘LIKE’, ‘value’ => $value_here ) ) ); You can read more about meta queries … Read more

Merge two queries and remove duplicate

Why not do something like this? $fav_author_list = get_user_option( ‘favorite-authors’, fav_authors_get_user_id() ); $fav_category_list = get_user_option( ‘favorite-categories’, fav_categories_get_user_id() ); if(!empty($fav_author_list) && !empty($fav_category_list)) { $rm_args = array( ‘posts_per_page’ => -1, ‘author__in’=> $fav_author_list, ‘category__in’=> $fav_category_list, ‘post_type’ => ‘post’ ); } elseif(!empty($fav_author_list) && empty($fav_category_list)) { $rm_args = array( ‘posts_per_page’ => -1, ‘author__in’=> $fav_author_list, ‘post_type’ => ‘post’ ); } elseif(empty($fav_author_list) … Read more