从get_terms()创建的术语对象的name属性中删除post格式前缀。

原型

_post_format_get_terms( array $terms, string|array $taxonomies, array $args )

参数

$terms (array) (Required)

$taxonomies (string|array) (Required)

$args (array) (Required)

返回值

(array)  

源文件

路径:wp-includes/post-formats.php

<?php
...
function _post_format_get_terms( $terms, $taxonomies, $args ) {
	if ( in_array( 'post_format', (array) $taxonomies ) ) {
		if ( isset( $args['fields'] ) && 'names' == $args['fields'] ) {
			foreach ( $terms as $order => $name ) {
				$terms[$order] = get_post_format_string( str_replace( 'post-format-', '', $name ) );
			}
		} else {
			foreach ( (array) $terms as $order => $term ) {
				if ( isset( $term->taxonomy ) && 'post_format' == $term->taxonomy ) {
					$terms[$order]->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) );
				}
			}
		}
	}
	return $terms;
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/_post_format_get_terms/