我有一个可湿性粉剂的网站与投资组合部分。在项目组合页面上,它显示了项目类别。我只想用id=63显示父类别的子类别。
这是当前的代码:
<?php $terms = get_the_terms( $post->ID , 'portfolio_category', 'string' ); ?>
<?php $num_of_terms = count($terms); ?>
<?php if($terms) { ?>
<div class="meta-column">
<strong class="caps"><?php esc_html_e( 'Artist', 'onioneye' ); ?><span class="colon">:</span></strong>
<span>
<?php
$i = 0;
foreach($terms as $term) {
if($i + 1 == $num_of_terms) {
echo esc_html($term -> name);
}
else {
echo esc_html($term -> name . ', ');
}
$i++;
}
?>
</span>
</div>
<?php } ?>发布于 2017-04-20 12:42:20
你能试试这个吗:
$args = array('child_of' => 63);
$terms = get_categories( $args );代替它的是:
$terms = get_the_terms( $post->ID , 'portfolio_category', 'string' );https://stackoverflow.com/questions/43503271
复制相似问题