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

meta_query, number comparison, not quite working as it should

Firstly, there’s no point in converting to ‘meta_query’ if you’re dealing with a single custom field. Secondly, ‘meta_query’ doesn’t handle ordering. Finally, since your date is in the ‘Ymd’ format, comparing them as numbers will produce incorrect results. In your initial code, they are compared as strings.

Wildcard with LIKE operator in Meta query

Have you var_dumped $location? WP_Query‘s meta_query uses the class WP_Meta_Query, which automatically appends and prepends ‘%’ to any string passed to it: // From wp-includes/class-wp-meta-query.php:610 switch ( $meta_compare ) { // … case ‘LIKE’ : case ‘NOT LIKE’ : $meta_value=”%” . $wpdb->esc_like( $meta_value ) . ‘%’; $where = $wpdb->prepare( ‘%s’, $meta_value ); break; // … … Read more

Use both meta query and tax query

Would you believe it, as soon as I posted this I remembered I asked a question about a query last year. I had a look over it and I’ve adapted my new query like so: $category_slug = filter_input( INPUT_GET, ‘eventtype’, FILTER_SANITIZE_STRING ); $cat_query = []; if( $event_type ){ $cat_query = [ [ ‘taxonomy’ => ‘eventtype’, … Read more

Display no post when metavalue is 0

Here’s an updated example that appears to do what you want. See the docs for meta queries for details. $query_args = [ ‘post_type’ => ‘list’, ‘posts_per_page’ => 3, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘meta_query’ => [ [ ‘key’ => ‘post_views_count’, ‘value’ => 50, ‘compare’ => ‘>’, ‘type’ => ‘NUMERIC’, ], ], ]; $post_views_query = … Read more

Edit post_content on posts with Featured Image

I would do this as follows: Back up the entire DB (or certainly the wp_posts table!) Run this query to get all posts that have a featured image: SELECT wp_posts.* FROM wp_postmeta INNER JOIN wp_posts ON (wp_postmeta.post_id = wp_posts.ID) AND meta_key=’_thumbnail_id’; Export the results to a plain SQL file with SQL inserts Do your search … Read more

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