[wp-trac] [WordPress Trac] #42629: The function the_meta () outputs an empty list
WordPress Trac
noreply at wordpress.org
Sun Nov 19 19:43:11 UTC 2017
#42629: The function the_meta () outputs an empty list
--------------------------------+-----------------------------
Reporter: campusboy1987 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Options, Meta APIs | Version: trunk
Severity: normal | Keywords:
Focuses: template |
--------------------------------+-----------------------------
Hello. The problem is that if the post has only protected arbitrary
fields, the function the_meta () displays a list without li elements,
which is not correct. I propose the following changes:
{{{
#!php
<?php
function the_meta() {
if ( $keys = get_post_custom_keys() ) {
$li_html = '';
foreach ( (array) $keys as $key ) {
$keyt = trim( $key );
if ( is_protected_meta( $keyt, 'post' ) ) {
continue;
}
$values = array_map( 'trim',
get_post_custom_values( $key ) );
$value = implode( $values, ', ' );
$html = sprintf( "<li><span class='post-meta-
key'>%s</span> %s</li>\n",
/* translators: %s: Post custom field name
*/
sprintf( _x( '%s:', 'Post custom field
name' ), $key ),
$value
);
/**
* Filters the HTML output of the li element in
the post custom fields list.
*
* @since 2.2.0
*
* @param string $html The HTML output for the li
element.
* @param string $key Meta key.
* @param string $value Meta value.
*/
$li_html .= apply_filters( 'the_meta_key', $html,
$key, $value );
}
if ( $li_html ) {
echo "<ul class='post-meta'>\n$li_html</ul>\n";
}
}
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42629>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list