Tell us what you are trying to do?
I am filtering a view, comparing a date field with YEARS_FROM_NOW() for the years 1892 to 1918.
I removed the page from the cache. (but the provider cannot take it out of the server cache)
When refreshing the page, the date filter does not update the search, meaning that the page stays on 'yesterday's date', instead of filtering on the date field.
The only way that works consistently to get it refreshed, is to go into WP and open the page in the editor, and update the page. After that, the 'on this day' page correctly filters 'today' and shows the events on this day.
When someone views the page for the first time, it works fine.
I simply go to the page each day and manually update it, but would like to have this automatic/automated.
Is there any documentation that you are following?
Toolset doc
Is there a similar example that we can see?
You would have to test this over several days, by simply going to hidden link and checking the events shown. Sometimes there are no events on a date, which makes it difficult to check the date; just re-test the next day until you have an event visible.
What is the link to your site?
This is the page: hidden link
Hi there,
It seems to be a problem of cache and you will need to either turn off the cache for the page or somehow automate the page update.
The code below might help for the second scenario as I do not know enough about the first scenario.
// Schedule an action if it's not already scheduled
if (! wp_next_scheduled ( 'my_daily_page_touch' )) {
wp_schedule_event(time(), 'daily', 'my_daily_page_touch');
}
// Hook into that action that'll fire daily
add_action('my_daily_page_touch', 'touch_page_daily');
function touch_page_daily() {
// The ID of the page that you want to touch
$page_id = 5975; // change this to your page ID
// Get the current page data
$page_data = get_post($page_id);
// Make a minor change (update the modified date)
$page_data->post_modified = current_time('mysql');
$page_data->post_modified_gmt = current_time('mysql', 1);
// Update the page without changing its last edit user
wp_update_post($page_data, true);
}
This code sets up a daily WordPress cron job that updates the modification date of the page with the ID you specify.
From the front end of the website I think the page ID is 5975 but if not please change it in the code.
Please note that this code should be added to your theme's functions.php file or a custom plugin file.
Finally, this is just an extra step to help if we could do something about it but there is no guarantee of a working solution and the best one is to deacitvate cache for the page.
Thanks.
The page has been removed from cache ages ago, but on the provider side it probably is still in the server cache, since they told me they cannot exclude one page.
I will try out your code, and come back to you. It takes a few days to test.
Very kind of you to provide the code snippit.
Thank you, we will wait for the result.
The code works. Thank you.
Would it be possible to code it to update the page at one second past midnight every day? Because, what does 'daily' currently mean in the code? When is 'daily'?
Hi there,
There is no control over that. You can use plugins such as the one below to control the schedule of the cron jobs:
https://wordpress.org/plugins/wp-crontrol/
Thanks.
for some reason I cannot close this ticket.
Thanks for the great support!
Close ticket.