What’s wrong with my date_query?

‘date_query’ argument takes an additional option that is ‘relation’ that can be AND or OR. If we consider the relation OR your code, that use exactly same date for ‘before’ and ‘after’ with ‘inclusive’ set to true, should return all your posts: posts before a date + posts after that date + posts in that … Read more

Display post from specific date

I think if you want to show recent posts posted 2-3 days ago, you can use date queries, provided by WordPress You can get more information about date queries from here: WordPress Date Queries For Example: If you want to show last three days posts, it can be done using the following snippet of code: … Read more

Individually styling date month year [closed]

As suggested, you can break down the date format in different parts. echo ‘<span class=”date-day”>’ . get_the_date( ‘d’ ) . ‘</span>’; echo ‘<span class=”date-month”>’ . get_the_date( ‘M’ ) . ‘</span>’; echo ‘<span class=”date-year”>’ . get_the_date( ‘Y’ ) . ‘</span>’; Now each item have class associated with it, so you can style each differently as you … Read more

$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