Created
December 5, 2014 14:09
-
-
Save ChrisCree/d790520452e80589dd87 to your computer and use it in GitHub Desktop.
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.
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 | |
// 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