the_meta()

Display list of post custom fields.


Description Description


Source Source

File: wp-includes/post-template.php

function the_meta() {
	if ( $keys = get_post_custom_keys() ) {
		echo "<ul class='post-meta'>\n";
		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.
			 */
			echo apply_filters( 'the_meta_key', $html, $key, $value );
		}
		echo "</ul>\n";
	}
}

Top ↑

Changelog Changelog

Changelog
Version Description
1.2.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.