March 11, 2017 by Sridhar Katakam
.new {
margin-right: 8px;
font-size: 15px;
}
Install and activate this customized Custom Genesis Featured Posts Widget plugin: http://d.pr/f/r5GB
/**
* Function to check if a post is older than certain days
*
* @param integer $days Number of days.
* @return True if post is older than the supplied number of days, otherwise false
* @link http://wpengineer.com/1913/if-post-is-older-than/
*/
function is_old_post( $days = 5 ) {
$days = (int) $days;
$offset = $days * 24 * 60 * 60;
if ( get_post_time() < date( 'U' ) - $offset ) {
return true;
}
return false;
}
add_filter( 'genesis_post_title_output', 'custom_post_title_output' );
/**
* Filter Genesis Post Titles to add a [NEW] label for posts that have been published within the last 90 days.
*
* @param string $output Current title output markup.
*/
function custom_post_title_output( $output ) {
// if this is a Post and is NOT older than 90 days i.e., was published in the last 90 days.
if ( 'post' === get_post_type() && ! is_old_post( 90 ) ) {
$output = '<span class="new alignleft">[NEW]</span>' . $output;
}
return $output;
}