Searching in meta_value or title
-
I tried to filter the sql produced by get_meta_sql(), following this article: https://wordpress.stackexchange.com/questions/178484/wp-query-args-title-or-meta-value
It works… more or less. If I intoduce a tax query together with the meta query, the sql loose all the “meta” part.
Without the tax query, the SQL produced is like the following:
["where"]=> string(395) " AND ( tm_posts.post_title like '{0acc5f40973efce47f8c42124c3734c97cc594f755a60224e0dd4cb02827c6b6}lorem{0acc5f40973efce47f8c42124c3734c97cc594f755a60224e0dd4cb02827c6b6}' OR ( ( tm_postmeta.meta_key = 'codice_linea' AND tm_postmeta.meta_value LIKE '{0acc5f40973efce47f8c42124c3734c97cc594f755a60224e0dd4cb02827c6b6}lorem{0acc5f40973efce47f8c42124c3734c97cc594f755a60224e0dd4cb02827c6b6}' )
With the important tax query it becomes like this
["where"]=> string(177) " AND ( tm_posts.post_title like '{0406194437bac6b8187ce05f3bb4eecb83f0178715b7c8ca750a672ba53df8ac}lorem{0406194437bac6b8187ce05f3bb4eecb83f0178715b7c8ca750a672ba53df8ac}' OR ) "
As you all can see, all the part related to the meta query disappears.
Why? ??
These are part of the query args
$args['tax_query'] = array( 'relation' => 'AND', array( 'taxonomy' => 'stagione_linea', 'field' => 'slug', 'terms' => 'estate' ) ); $args['meta_query'] = array( array( 'key' => 'codice_linea', 'value'=> $term, 'compare' => 'LIKE', ) ); // this arg is added to activate the filter (see linked article) $args['_meta_or_title'] = $term;
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Searching in meta_value or title’ is closed to new replies.