Ich möchte folgendes HTML vor und nach einem Post-Inhalt hinzufügen:
// post content
Wie kann ich dies für alle bestehenden Posts automatisch tun?
Verwenden Sie den Filter ” the_content
. Auf diese Weise können Sie bestimmte Inhalte aus dem Inhalt anpassen / hinzufügen / entfernen
add_filter( 'the_content', function ( $content ) { // Make sure we only target the main query's content, adjust as needed if ( !in_the_loop() ) return $content; // We are targeting the correct content, so lets add what we need to $new_content = ''; $new_content .= $content; $new_content .= '
'; return $content = $new_content; });