【发布时间】:2014-11-21 14:03:06
【问题描述】:
我发现此功能可以显示附加到帖子的术语,但我无法找到一种方法来排除我不想在列表中显示的某些类别术语的特定 ID。 有人可以给我一个线索吗?我查找了此函数中使用的所有函数,但似乎找不到排除 id 的参数。
提前致谢!
// get taxonomies terms links
function custom_taxonomies_terms_links() {
global $post, $post_id;
// get post by post id
$post = &get_post($post->ID);
// get post type by post
$post_type = $post->post_type;
// get post type taxonomies
$taxonomies = get_object_taxonomies($post_type);
$out = "<ul>";
foreach ($taxonomies as $taxonomy) {
// get the terms related to post
$terms = get_the_terms( $post->ID, $taxonomy );
if ( !empty( $terms ) ) {
foreach ( $terms as $term )
$out .= '<li><a href="' .get_term_link($term->slug, $taxonomy) .'">'.$term->name.'</a></li> ';
}
}
$out .= "</ul>";
return $out;
}
【问题讨论】: