Skip to content

Instantly share code, notes, and snippets.

@damiencarbery
Last active February 14, 2021 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damiencarbery/f37797250f7025334599506202d20a27 to your computer and use it in GitHub Desktop.
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.
<?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