wp_query not searching with apostrophe

Try using sanitize_text_field instead of esc_html wp> $search_query = “Dalton’s Law <br/>”; string(18) “Dalton’s Law <br/>” wp> $query = apply_filters( ‘get_search_query’, $search_query ); string(18) “Dalton’s Law <br/>” wp> $esc_html = esc_html( $query ); string(29) “Dalton&#039;s Law &lt;br/&gt;” wp> $sanitized = sanitize_text_field( $query ); string(12) “Dalton’s Law” esc_html should be used to escape output before it … Read more

WP_Query meta_query >= date

What is missing? One tiny detail… And it’s easy to overlook… the_field(‘datum_event’); Prints the field using the format you’ve defined in field settings. But… It has nothing to do with how the value of that field is stored in DB. ACF uses YYYYMMDD format when storing date values in DB. And WP_Query doesn’t use field … Read more

Order a query result by a numeric meta key even if it does not exist, but put the posts with meta key first

First of all, just to clarify, in a normal situation without the specific order requirements, and assuming you are doing this on pre_get_posts hook, you would just do as follows: add_action(‘pre_get_posts’, function ($query) { // only perform for a given query // do your checks and return early if (! $query->is_main_query() || ! $query->is_home()) { … Read more

Meta Query Compare with Date

It looks like it is the date format. I tried it with the format 2020/10/10 (YYYY/MM/DD) and it worked as expected. You can also use hyphens as delimiters (YYYY-MM-DD), or omit them entirely. Since you’ve already formatted the date, you don’t need to use the date() function. $metas[] = array( ‘key’ => ‘event_date’, ‘value’ => … Read more

Get Posts shortcode plugin and meta_query?

Besides the plugin not being updated, this will not work because the meta_query arg is evaluated as a string: array(3) { [“post_type”] => string(7) “project” [“meta_query”] => string(96) “array(array(‘key’ => ‘state’, ‘value’ => ‘Completed’),array(‘key’ => ‘year’,’value’ => ‘2006’))” [“suppress_filters”] => string(5) “false” } I suggest you make a custom page template, where you would directly … Read more

Custom query with DECIMAL(5,2)

Answer taken from here: meta_query: using BETWEEN with floats and/or casting to DECIMAL add_filter(‘get_meta_sql’,’cast_decimal_precision’); function cast_decimal_precision( $array ) { $array[‘where’] = str_replace(‘DECIMAL’,’DECIMAL(5,2)’,$array[‘where’]); return $array; }

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