diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php
index b80ac4d4e4..5443340970 100644
--- a/src/wp-includes/post-template.php
+++ b/src/wp-includes/post-template.php
@@ -1016,7 +1016,7 @@ function post_custom( $key = '' ) {
*/
function the_meta() {
if ( $keys = get_post_custom_keys() ) {
- echo "
\n";
+ $li_html = '';
foreach ( (array) $keys as $key ) {
$keyt = trim( $key );
if ( is_protected_meta( $keyt, 'post' ) ) {
@@ -1041,9 +1041,12 @@ function the_meta() {
* @param string $key Meta key.
* @param string $value Meta value.
*/
- echo apply_filters( 'the_meta_key', $html, $key, $value );
+ $li_html .= apply_filters( 'the_meta_key', $html, $key, $value );
+ }
+
+ if ( $li_html ) {
+ echo "\n";
}
- echo "
\n";
}
}