Single meta_query query using OR instead of AND in request’s WHERE statement

I believe the shortest and best approach is to (1) modify the query: function search_faqs_metadata($query) { if(!is_admin() && $query->is_main_query()) { if($query->is_search) { $query->set(‘meta_query’, array(array( ‘key’ => ‘_faqs’, ‘value’ => $query->query_vars[‘s’], ‘compare’ => ‘LIKE’ ))); } } } add_action(‘pre_get_posts’, ‘search_faqs_metadata’); and then (2) replace the AND with OR via the get_meta_sql filter: function change_meta_key_where_from_and_to_or($sql) { if(is_search()) … Read more

advanced search forms with 3 input text and that the main problem 3 input text

As you’ve already get results with tag I’m going to give suggestion only for address and rating. For your current situation, the best option is to use WordPress post meta to store these values. Then you can use meta query to retrieve those posts. $args = array( ‘post_type’ => ‘hotel’, ‘meta_query’ => array( array( ‘key’ … 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

WP_Query on custom field and order results

Change your code with this and might help you with what you are looking for. The issue here is that we cannot include key, order and orderby in meta_query. But if you want to order you result posts based on key than you can pass the query arguments as below: $custom_query_args = array( ‘post_type’ => … Read more

Using pre_get_posts for meta value of LIKE comparison on ACF repeater sub field

You need to add Wildcards to your meta_value. Change $query->set(‘meta_query’, array( array( ‘meta_key’ => ‘test_repeater_%_test_sub_field’, ‘meta_value’ => $search, ‘compare’ => ‘LIKE’, ), )); To $query->set(‘meta_query’, array( array( ‘meta_key’ => ‘test_repeater_%_test_sub_field’, ‘meta_value’ => ‘%’.$search.’%’, ‘compare’ => ‘LIKE’, ), ));

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