我已经注册了一个名为“type”的分类法,并将其链接到自定义的Post类型“group”。
我只想输出分类法“type”的术语归档链接条目。
我已经注册了一个名为“type”的分类法,并将其链接到自定义的Post类型“group”。
我只想输出分类法“type”的术语归档链接条目。
在中找到此代码official Wordpress Function Reference:获取一个分类法的所有存档链接术语的简单方法。
列出所有术语,并链接到术语存档,由Interpunt(·)分隔:
$args = array( \'hide_empty=0\' );
$terms = get_terms(\'my_term\', $args);
if ( !empty( $terms ) && !is_wp_error( $terms ) ) {
$count = count($terms);
$i=0;
$term_list = \'<p class="my_term-archive">\';
foreach ($terms as $term) {
$i++;
$term_list .= \'<a href="\' . get_term_link( $term ) . \'" title="\' . sprintf(__(\'View all post filed under %s\', \'my_localization_domain\'), $term->name) . \'">\' . $term->name . \'</a>\';
if ($count != $i) {
$term_list .= \' · \';
}
else {
$term_list .= \'</p>\';
}
}
echo $term_list;
}
我试图创建一个页面,在其中一个页面上显示几个帖子。到目前为止还不错。一切正常。现在,我在foreach循环中显示帖子,检查它们是否连接到页面。我需要的是wp_get_post_terms($post->ID); 但这行不通。有custom registered_taxonomy\'s那么我怎样才能得到所有taxonomy names 通过$post->ID?