the_meta

函数


the_meta ( No parameters )
定义位置
  • wp-includes/post-template.php
    , line 1110
引入
1.2.0
弃用
6.0.2

显示一个文章自定义字段的列表。

function the_meta() {
	_deprecated_function( __FUNCTION__, '6.0.2', 'get_post_meta()' );
	$keys = get_post_custom_keys();
	if ( $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(
				"
  • %s
  • n”,
    /* translators: %s: Post custom field name. */
    esc_html( sprintf( _x( ‘%s:’, ‘Post custom field name’ ), $key ) ),
    esc_html( $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 “

    n”;
    }
    }
    }