Query with custom taxonomy not working

The solution is to use: ‘taxonomy’ => ‘meal’, ‘field’ => ‘slug’, ‘terms’ => ‘breakfast’ The taxonomy and terms are obvious, but why does field have to be slug? When you add taxonomy parameters, you can specify what ‘breakfast’ is– via the field. It could be the term’s ID, the full name, or slug. See the … Read more

Custom WP_QUERY $args

You can use custom filters in $args (not tested) add_filter( ‘posts_where’, ‘find_by_title_filter’, 10, 2 ); function find_by_title_filter( $where, &$wp_query ) { global $wpdb; if ( $find_title_arg = $wp_query->get( ‘find_title’ ) ) { $where .= ‘ AND ‘ . $wpdb->posts . ‘.post_title LIKE \’%’ . esc_sql( $wpdb->esc_like( $find_title_arg ) ) . ”; } return $where; } … Read more

Complex date range with WP_Query and BETWEEN

It’s a little hard to think in meta_query code for complicated case like this and without access to data. 🙂 What you have working can be expressed as two following conditions: start_date BETWEEN event_begin and event_end end_date BETWEEN event_begin and event_end Your first case with both in between seems irrelevant, since these two will catch … Read more

Complex Orderby Parameters: How to query with multiple orderby parameters using meta_value_num?

Boohoo why did I start a bounty for that 😉 The answer is pretty simple – add ‘type’ => ‘numeric’ to the meta query. array(5) { [“posts_per_page”]=> int(6) [“orderby”]=> array(2) { [“uss_product_price”]=> string(4) “DESC” [“uss_product_weight”]=> string(4) “DESC” } [“meta_query”]=> array(3) { [“relation”]=> string(3) “AND” [“sortprimary_clause”]=> array(3) { [“key”]=> string(17) “uss_product_price” [“compare”]=> string(6) “EXISTS” [“type”]=> string(7) … Read more