Last active
July 25, 2024 09:23
-
-
Save Zodiac1978/43c3fc13014ce82667bc4d5f34f84fd4 to your computer and use it in GitHub Desktop.
Show modified and published date with translated date in Divi posts
This file contains hidden or 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 | |
// See: https://www.elegantthemes.com/blog/divi-resources/how-to-add-the-last-updated-date-to-divis-blog-post-meta-data#option-4-displaying-both-the-publish-and-last-updated-dates-without-time | |
function et_last_modified_date_blog( $the_date ) { | |
if ( 'post' === get_post_type() && !is_admin() ) { | |
$the_time = get_post_time( 'His' ); | |
$the_modified = get_post_modified_time( 'His' ); | |
$last_modified = sprintf( __( 'Zuletzt aktualisiert am %s', 'Divi' ), esc_html( get_post_modified_time( 'j. F Y', false, get_the_id(), true ) ) ); | |
$published = sprintf( __( 'Veröffentlicht am %s', 'Divi'), esc_html( get_post_time( 'j. F Y', false, get_the_id(), true ) ) ); | |
$date = $the_modified !== $the_time ? $published . ' | ' . $last_modified : $published; | |
return $date; | |
} | |
return $the_date; | |
} | |
add_filter( 'get_the_date', 'et_last_modified_date_blog' ); | |
add_filter( 'get_the_time', 'et_last_modified_date_blog' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment