How to show certain data on certain interval of period

Here’s a function you can put in functions.php. function get_current_event() { global $post; $now = get_the_time(‘U’); $year = get_the_time(‘Y’); if($now >= strtotime(“January 1 $year”) && $now < strtotime(“March 1 $year”)) { return get_post_meta($post->ID,’eventA’,true); } if($now >= strtotime(“March 1 $year”) && $now < strtotime(“October 15 $year”)) { return get_post_meta($post->ID,’eventB’,true); } $nextyear = $year+1; if($now >= strtotime(“October … Read more

How to add correct Last update in Postings (the_modified_time)

You could compare post_date to post_modified and only echo your content if they do not match. // inside a Loop if ($post->post_date != $post->post_modified) { ?> <span style=”font-size:85%”>Last update <u><time datetime=”<?php the_modified_time(‘d-m-y’); ?>”> <?php the_modified_time(‘l j F, Y’); ?></time></u></span><?php } If you want “significant” updates, though, you will need to determine what counts as significant … Read more

Problems with the_time,the_date, get_the_time

When using date function it is recommanded to use date format or time format of the installation : get_option(‘time_format’); get_option(‘date_format’); This allows you to grab date format or time format of the current installation.

How do I convert all custom_field php timestamps in the database to js timestamps?

ACF using milliseconds is not standard for timestamps, and nor is it useful. How much accuracy do you need? Bear in mind that converting to something like yyyymmdd will not accommodate timezones. If you have access to PHPMyAdmin (or similar) and know your way around SQL, running a quick query would probably be the easiest … Read more

Redirect to URL if x number of days passed

To redirect after 3 days gone after publication, hook into template_redirect, check if is a singular cpt view, check the date and compare to current time and redirect if needed. In the 3 days time frame, check if stats is is the query vars and if so redirect to post page. add_action(‘template_redirect’, ‘check_the_date_for_stats’); function check_the_date_for_stats() … Read more