Add “NEW” icon after recent post title

You might want to show a “NEW” icon after your latest posts’ title.
Please add this code to file functions.php of your active theme:

// Content Views Pro - Show custom icon in title
add_filter( 'pt_cv_field_title_result', 'cvp_theme_title_new_icon', 100, 3 );
function cvp_theme_title_new_icon( $title, $fargs, $post ) {
	$hours	 = 24; /* TODO: change this value to number of hours to calculate */
	$diff	 = time() - mysql2date( 'U', $post->post_date );

	if ( $hours * 60 * 60 > $diff ) {		
		// 1. To show a "New" icon/image, remove the 2. below
		$title = $title . "<img src='IMAGE_URL_HERE' />";
		
		// 2. To show a "New" text, remove the 1. above
		$title = $title . "<span style='padding:2px 8px;color:#fff;background:red;margin-left:5px;'>New</span>";
	}

	return $title;
}

Thank you,

Scroll to Top