Archived topic
How to completly hide the date on old posts
3 replies · Started by Patrick on November 22, 2016
Hello Tom,
I know I can Hide the post date from post in the customizer. That works fine for all posts, but I would like to hide the date only from posts that are like two years old.
I have the plugin wp old post date remover which works fine by hiding the date for the user (through css), but still google sees the date.
Perhaps it would help if i knew what filter, acton etc is jused by the customizer to remove the date, then i could perhaps make the old post date remover plugin use that.
Thank you
Hi there,
Not sure it will work, but you could try something like this:
add_filter( 'generate_post_date','tu_hide_old_post_dates' );
function tu_hide_old_post_dates()
{
global $post;
if( strtotime( $post->post_date ) < strtotime('-730 days') ) {
return false;
}
return true;
}
Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/
Let me know :)
Thank you Tom,
it seems to work great in my functions.php
You're welcome :)