$wpdb->get_results returns empty but value exists

It is hard to say without hands on access to your data. Either the query is actually failing or the query is not something you expect in that context. You should enable error reporting via $wpdb->show_errors( true ) before it and check $wpdb->last_query for sanity after.

Complex date range with WP_Query and BETWEEN

It’s a little hard to think in meta_query code for complicated case like this and without access to data. 🙂 What you have working can be expressed as two following conditions: start_date BETWEEN event_begin and event_end end_date BETWEEN event_begin and event_end Your first case with both in between seems irrelevant, since these two will catch … Read more

Show a different post every 3 days [duplicate]

Your code example isn’t random though, it’s a fixed offset, based on a week number. As stated this isn’t something that can be expressed in query API I think. You would probably have to keep track of state with something like following algorithm: Query a random post, store its ID Store a date three days … Read more

Use current date as tag?

We can use e.g. current_time( ‘d-m-y’ ) to get the formatted current date. So you could try: $wpb_all_query = new WP_Query( [ ‘tag’ => current_time( ‘d-m-Y’ ) ] ); Also note the date_query parameter, if you want to target the post date part instead.

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

How to translate functions like get_the_date()?

Why not do it in plain PHP? For example, you can write a function like: function get_the_german_date($date=””, $post = null) { $d = get_the_date($date, $post); if ($d) { $d = new DateTime($d); return $d->format(‘d.m.Y’); } else return false; } Similary, if you want to follow the WordPress standards: function the_german_date($date=””, $post = null) { $d … Read more

What are the “U” and “G” time formats?

The U and G are not WordPress specific. get_post_time() is using the same datetime formats as the default PHP date method. Here is the documentation for all of the formats: https://www.php.net/manual/en/function.date.php Specific to the question: U is Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) G is 24-hour format of an hour without … Read more

Calculate future date

try $future_timestamp = strtotime(‘+1 week’, get_the_date(‘Y-m-d’)); echo date(‘Y-m-d’, $future_timestamp); or $future_timestamp = get_the_date(‘U’) + (60 * 60 * 24 * 7); echo date(‘Y-m-d’, $future_timestamp);

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