Skip to content

Instantly share code, notes, and snippets.

@WordPress-Handbuch
Created March 14, 2019 09:36
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 WordPress-Handbuch/797563a63bbded687e589ecf0ec916a7 to your computer and use it in GitHub Desktop.
Save WordPress-Handbuch/797563a63bbded687e589ecf0ec916a7 to your computer and use it in GitHub Desktop.
Extending a WordPress theme's single.php template file to output custom post fields (meta-boxes), (tested for Twenty Nineteen)
if ( $custom = get_post_custom() ) {
$location = ( isset($custom['location'][0] )) ? 'in ' . $custom['location'][0] : '';
$eventdate = ( isset($custom['eventdate'][0] )) ? 'am ' . date_i18n(get_option( 'date_format' ), strtotime($custom['eventdate'][0])) : '';
if ( !empty( $location ) || !empty ($location)) {
echo ' <h3 class="comments-area">Veranstaltung ' . $location . ' ' . $eventdate . '</h3>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment