_post_format_wp_get_object_terms

函式
_post_format_wp_get_object_terms ( $terms )
Access
Private
引數
  • (array) $terms
    Required:
返回值
  • (array)
定義位置
相關方法
_post_format_get_terms_post_format_get_termwp_get_object_termswp_set_object_termswp_add_object_terms
引入
3.1.0
棄用
-

_post_format_wp_get_object_terms: 這個函式用於獲取與特定文章格式的文章相關的術語。它需要兩個引數,$post_id和$format,它們分別是文章的ID和文章格式的slug: 當你想顯示與某一特定格式的文章相關的術語時,通常使用這個函式。

從wp_get_object_terms()建立的術語物件的名稱屬性中刪除文章格式字首。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function _post_format_wp_get_object_terms( $terms ) {
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;
}
function _post_format_wp_get_object_terms( $terms ) { 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; }
function _post_format_wp_get_object_terms( $terms ) {
	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;
}

常見問題

FAQs
檢視更多 >