Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Function for customizing the Genesis post info function based on date post was published. For example the below function shows different post info for posts more than 6 months old. Adjust as required.
<?php
// Don't copy opening PHP tag above
// Customize the post info function by date
add_filter( 'genesis_post_info', 'wsm_post_info_filter' );
function wsm_post_info_filter( $post_info ) {
$post_date = the_date( 'Y-m-d','','', false );
$date_limit = date( "Y-m-d", mktime(0,0,0,date("m")-6, date("d"), date("Y")) );
$post_info = '';
if ( $post_date > $date_limit ) {
$post_info = '[post_date format="F j, Y"] [post_author before="<em>by</em> "] [post_comments zero="No Comments" one="1 Comment" more="% Comments"]';
}
else {
$post_info = '[post_author before="<em>by</em> "] [post_comments zero="No Comments" one="1 Comment" more="% Comments"]';
}
return $post_info;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.