Last active
February 14, 2021 11:34
-
-
Save damiencarbery/f37797250f7025334599506202d20a27 to your computer and use it in GitHub Desktop.
Genesis Hide Old Post Dates - Do not show post date on posts older than 30 days.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Genesis Hide Old Post Dates | |
Plugin URI: https://www.damiencarbery.com/2021/02/hide-old-post-dates-in-genesis/ | |
Description: Do not show post date on posts older than 30 days. | |
Author: Damien Carbery | |
Author URI: https://www.damiencarbery.com | |
Version: 0.2 | |
*/ | |
function dcwd_hide_old_post_info($post_info) { | |
$now = time(); // Get current time in "seconds since epoch" format. | |
$date = get_the_date( 'U' ); // Get post date in "seconds since epoch" format. | |
// If post is more than 30 days old then change the post info to remove post date. | |
if ( $now - $date > MONTH_IN_SECONDS ) { | |
$post_info = str_replace( '[post_date]', '', $post_info ); | |
} | |
return $post_info; | |
} | |
add_filter('genesis_post_info', 'dcwd_hide_old_post_info'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment