Php Wordpress公文包:仅显示子类别
我有一个可湿性粉剂与投资组合部分的网站。 在公文包页面上显示项目类别。 我想只显示id=63的父类别的子类别 这是当前代码:Php Wordpress公文包:仅显示子类别,php,jquery,wordpress,Php,Jquery,Wordpress,我有一个可湿性粉剂与投资组合部分的网站。 在公文包页面上显示项目类别。 我想只显示id=63的父类别的子类别 这是当前代码: <?php $terms = get_the_terms( $post->ID , 'portfolio_category', 'string' ); ?> <?php $num_of_terms = count($terms); ?> <?php if($terms) { ?>
<?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 } ?>
:
您能试试这个吗:
$args = array('child_of' => 63);
$terms = get_categories( $args );
取而代之的是:
$terms = get_the_terms( $post->ID , 'portfolio_category', 'string' );