Skip to content

Instantly share code, notes, and snippets.

@nextab
Last active February 8, 2022 15:57
Show Gist options
  • Select an option

  • Save nextab/88b8bf243db80d483aefd31ffb12922b to your computer and use it in GitHub Desktop.

Select an option

Save nextab/88b8bf243db80d483aefd31ffb12922b to your computer and use it in GitHub Desktop.
Mit diesen beiden Code-Schnipseln lässt sich entweder das aktuelle Datum per PHP Code in WordPress ausgeben oder das Veröffentlichungsdatum eines Beitrags.
// Shortcode [releasedate] zeigt das AKTUELLE DATUM an.
function release_date_shortcode($atts, $content = null) {
$today = date_i18n('l, j. F Y');
return '<div class="date_container">Veröffentlicht am: ' . $today . '</div>';
}
add_shortcode('releasedate', 'release_date_shortcode');
// falls du das VERÖFFENTLICHUNGSDATUM des Beitrags ausgeben möchtest, verwende stattdessen diesen Code:
function release_date_shortcode($atts, $content = null) {
$today = date_i18n('l, j. F Y');
return '<div class="date_container">Veröffentlicht am: ' . get_the_date('l, j. F Y') . '</div>';
}
add_shortcode('releasedate', 'release_date_shortcode');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment