0
我有一個WP網站的投資組合部分。 在投資組合頁面上顯示項目類別。 我想僅顯示id = 63的父類別的子類別。WordPress的投資組合:只顯示子類別
這是當前的代碼:
<?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 } ?>
謝謝,但沒有奏效。 –