Archived topic
Only show published and updated dates if the post is 6 months old or younger
3 replies · Started by Simon on November 8, 2021
Viewing posts 1–4 of 4
I want to show the published (or updated) date below the post (I already opened a topic for that here: https://generatepress.com/forums/topic/show-the-date-at-the-end-of-the-post/ ).
Now I want to only show this date if the post is not older than 6 months. Is there a way to do this?
Hi there,
Try adding this PHP Snippet:
add_filter( 'generate_post_date_output', function($post_date){
if( get_the_time( 'U' ) < strtotime('-180 days') ) {
return null;
}
return $post_date;
},15,2);
works perfectly! thank you
Glad to heat that!
This archived topic is closed to new replies.