Skip to content

Instantly share code, notes, and snippets.

@gmmedia
Last active March 11, 2023 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmmedia/2bd02fa2631d9510f3d8aefaf14ec9d0 to your computer and use it in GitHub Desktop.
Save gmmedia/2bd02fa2631d9510f3d8aefaf14ec9d0 to your computer and use it in GitHub Desktop.
Artikel und Seiten Aktualisierungsdatum
<?php
// Änderungsdatum automatisch einfügen
function j0e_change_date($content) {
if ( (is_single() && get_post_type() == 'post') || is_page() ) {
$artikel_erstellt = get_the_date('U');
$artikel_aktualisiert = get_post_modified_time('U');
// Nur ausgeben, wenn Aktualisierung älter als einen Tag ist
if (($artikel_aktualisiert - $artikel_erstellt) > 86400)
{
$content = 'Artikel aktualisiert am ' . get_the_modified_date('d.m.Y') . $content;
}
}
return $content;
}
add_filter('the_content', 'j0e_change_date');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment