Change published date to sermon date on frontend
-
Hi, I’m using the Genesis Framework and Sermon Manager. I’m trying to find a way to make the published date of each sermon post be the same as the sermon date, when it’s displayed in an archive on the website.
Genesis has a shortcode called [post_date] which is used to display the post date (obviously) in the post entry header area for each post. My goal is to replace the date used in that shortcode with the actual sermon date – ie. the date saved in the sermon post meta as “sermon_date”.
I found a disabled function in Sermon Manager’s “template-tags.php” file, which is supposed to do exactly that. It looks like this:
function wpfc_sermon_date_filter() { global $post; if ( 'wpfc_sermon' == get_post_type() ) { $ugly_date = get_post_meta( $post->ID, 'sermon_date', 'true' ); // seems like it was stored as a text in the db sometime in the past if ( ! is_numeric( $ugly_date ) ) { $ugly_date = strtotime( $ugly_date ); } $date = date( get_option( 'date_format' ), $ugly_date ); return $date; } } add_filter('get_the_date', 'wpfc_sermon_date_filter');
I enabled this function and put it into my functions.php but it isn’t working as expected.
After further research I think I know why: the function above updates the “get_the_date” value with the sermon date. However, Genesis’s [post_date] shortcode is calling “get_the_time” rather than “get_the_date”. Therefore the Genesis shortcode doesn’t grab the date that the above function has modified.
Can anyone offer me a solution to ge this working the way I’d like it to? I did try modifying the function above so that the add_filter line modified “get_the_time”, but that didn’t work correctly.
For reference, here is the Genesis code for the [post_date] shortcode: https://genesis.wp-a2z.org/oik_api/genesis_post_date_shortcode/ (in the “Source” section in the middle of the page)
Thanks!
- The topic ‘Change published date to sermon date on frontend’ is closed to new replies.