这应该是非常直截了当的,我期待着学习如何做到这一点。
下面的代码仅排除顶层父级。我如何修改这段代码以排除下一个级别的下降?
例:
我的等级术语是World>Country>USA
我想展示的是美国而不是世界或国家
$terms = get_the_terms( $post->ID, 'From' );
if ( !empty( $terms ) ) {
$output = array();
foreach ( $terms as $term ){
if( 0 != $term->parent )
$output[] = '<a href="' . get_term_link( $term ) .'">' . $term->name . '</a>';
}
if( count( $output ) )
echo '' . __('Categories:','om_theme') . '</b> ' . join( ", ", $output ) . '';
}发布于 2014-02-06 02:33:42
echo '' . __('Categories:','om_theme') . '</b> ' . end($output) . '';https://stackoverflow.com/questions/21571354
复制相似问题