【发布时间】:2015-05-12 14:45:02
【问题描述】:
我需要更改下面的函数,以便它输出链接列表而不是字符串。所以我需要的结果html是<a href="#">term</a>。
function my_post_terms() {
// Get an array of all taxonomies for this post
$taxonomies = get_taxonomies( '', 'names' );
// Are there any taxonomies to get terms from?
if ( $taxonomies ) {
// Call the wp_get_post_terms function to retrieve all terms. It accepts an array of taxonomies as argument.
$arr_terms = wp_get_post_terms( get_the_ID(), array_values( $taxonomies ) , array( "fields" => "names" ) );
// Convert the terms array to a string
$terms = implode( ' ',$arr_terms );
// Get out of here
return $terms;
}
}
【问题讨论】:
-
一个简单的
foreach应该可以解决问题。 -
你会在函数的什么地方写这个?
标签: php wordpress function categories