WP_query with OR relation between args[‘s’] and arg[‘meta_query’]

Try this: $query = new WP_Query( array( ‘meta_query’ => array( ‘relation’ => ‘OR’, ‘resume_skills_clause’ => array( ‘key’ => ‘_resume_skills’, ‘value’ => $_GET[‘resume_search_keyword’], ‘compare’ => ‘LIKE’ ), ‘resume_job_duties_clause’ => array( ‘key’ => “_resume_job_duties”, ‘value’ => $_GET[‘resume_search_keyword’], ‘compare’ => ‘LIKE’ ) ) ));

Query posts from category A, and from either category B or C

Not sure this is the best way, but I have managed to get the desired result set with following $args parameters. $args[‘tax_query’] = array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘id’, ‘terms’ => array(100), ), array( ‘taxonomy’ => ‘category’, ‘field’ => ‘id’, ‘terms’ => array(105,106), ), );

Order by meta value (numeric value lower to higher)

I think that what you’re looking for is this: <?php $tours = new WP_Query(array( ‘post_type’ => ‘tour’, ‘posts_per_page’=> 12, ‘meta_key’ => ‘tour_price’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’ )); Descending means going down, as in, high to low. Ascending is going up, low to high.

wp_reset_postdata() does not work as expected

If this should be your main loop, the preferable way to modify the main loop is to use the pre_get_posts filter. For a secondary, it’s okay to use WP_Query, but you’re setting query arguments the wrong way. WP_Query expects an array of arguments. $args = array( ‘cat’ => 1 ); $general_posts = new WP_Query( $args … Read more

How do I exclude the lowest level terms in a taxonomy?

If you have only 4 level, and each third level term has children, the we can determine the fourth level term if have children: $term_id = get_queried_object()->term_id; $taxonomy_name=”product_range”; $custom_terms = get_term_children( $term_id, $taxonomy_name ); foreach ( $custom_terms as $custom_term ) { $term = get_term_by( ‘id’, $custom_term, $taxonomy_name ); $terms_chilren = get_term_children( $term_id, $taxonomy_name ); wp_reset_query(); … Read more