-
Hello, I want to change the timing of %currentdate% when adding it to the Post Meta Title and Description. The %currentdate% changes to the current date at 12:00 a.m., I think. But I want it to automatically change at 2:00 PM in the morning.
I tried getting code for this using Chat GPT and that did some help it was working but it created some conflict and removed the post title from the meta and showed only the date.
Chat GPT gave me this code –
// Function to dynamically generate meta title
function custom_meta_title($title) {
// Check if the current time is after 2:00 PM (14:00)
if (strtotime(current_time('H:i')) >= strtotime('14:00')) {
// It's 2:00 PM or later, so set the meta title to the current day's date
$title = date('j F Y') . ' - Your Custom Title'; // Replace 'Your Custom Title' with your desired title
} else {
// It's before 2:00 PM, so set the meta title to the previous day's date
$title = date('j F Y', strtotime('-1 day')) . ' - Your Custom Title'; // Replace 'Your Custom Title' with your desired title
}
return $title;
}
add_filter('rank_math/frontend/title', 'custom_meta_title');But, this caused some conflict and that post title disappeared. Please throw some light on how can I achieve it.
Thanks –
The ticket ‘Change %currentdate% timing to update on post meta’ is closed to new replies.