How to get events using multiple custom meta fields?

You can use your current code to create the query and then in your loop run a check before displaying the events something like <?php query_posts(‘meta_key’ => ‘end_date_value’, ‘meta_compare’ => ‘>’, ‘meta_value’ => $todaysDate); while ( have_posts() ) : the_post(); $post_custom = get_post_custom($post_id); if ($startDate < $post_custom[‘start_date_value’]){ //your loop here } } ?> keep in … 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

Comparing between a negative and positive number

I tried the following code: $posts = get_posts([ “post_type” => “CUSTOM_POST_TYPE”, “meta_query” => [ ‘relation’ => ‘AND’, [ ‘key’ => ‘longitude’, ‘value’ => [-0.9895, 1.3125], ‘compare’ => ‘BETWEEN’, “type” => “NUMERIC”, ], ], ]); When I remove “type” => “NUMERIC”, I could reproduced your problem because the comparison is string based. But when adding the … Read more

Check to see if page exists problems

Why are you comparing $post->post_name to $this->title? You should be comparing slug to slug. Try changing your comparison from this: if( strtolower( $page->post_name ) == strtolower( $this->title ) ) …to this: if( strtolower( $page->post_name ) == strtolower( $this->slug ) ) Also, I might suggest keeping with the WordPress object conventions with your dynamically created pages, … Read more

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