Query posts using less than

How about something like this? $args = array( ‘date_query’ => array( array( ‘before’ => array( ‘year’ => 2013, ‘month’ => 2, ‘day’ => 28, ), ‘inclusive’ => true, ), ), ‘posts_per_page’ => -1, ); $query = new WP_Query( $args ); Obviously you could set the exact date from a variable. More info: https://codex.wordpress.org/Class_Reference/WP_Query

tribe_get_start_time displays the current date and time on other post types than tribe_events

There are various ways to solve this. First coming to mind are checking via is_singular() or get_post_type(). Using the latter you could write foreach( $posts as $p ): setup_postdata( $p ); $post_type = get_post_type($p); if ($post_type === Tribe__Events__Main::POSTTYPE) { //or: if ($post_type === ‘tribe_events’) { // Display the date of the event $p_event = tribe_get_start_time … Read more

Compare meta key to current date in pre get post

What you’re trying isn’t possible with WP_Query. The reason is that because you have only stored the duration, it’s not possible to tell whether a post has expired until you know the publication date and the duration time and add them together. That’s what this does: $expire = get_field( ‘status_time_duration’ ) + get_the_time( ‘U’ ); … Read more

How to get User Time Zone in WordPress?

Since WordPress is a server-side framework/CMS, it likely doesn’t have the functionality you’re looking for. If you’re looking for ways to obtain this information, the most reliable would likely be to ask the user. To make it as painless as possible for the user, this functionality could be achieved via client-side scripting (ie. JavaScript) where … Read more

Why do I need to set my PHP timezone when it’s already set in WordPress?

In functions.php if I add date_default_timezone_set( get_option(‘timezone_string’) ); then $dt will output correctly with “PST”. Yes, but, “don’t change PHP time zone with date_default_timezone_set() (this one is hard requirement for correct core operation!)” — https://make.wordpress.org/core/2019/09/23/date-time-improvements-wp-5-3/. I didn’t think I needed to explicitly set the timezone since I already set it in WordPress WordPress does use … Read more