<?php
// names / IDs of parents
$parents = array(
\'par2\' => 76
);
// get post categories
$categories = get_the_terms( $post->ID, \'category\' );
// output top level cats and their children
foreach( $parents as $parent_name => $parent_id ):
// output parent name and link
//echo \'<a href="\' . get_term_link( $parent_id, \'category\' ) . \'">\' . $parent_name . \'</a>: \';
// initialize array to hold child links
$links = array();
foreach( $categories as $category ):
if( $parent_id == $category->parent ):
// put link in array
$links[] = \'<li><a href="\' . get_term_link( $category ) . \'">\' . $category->name . \'</a></li>\';
endif;
endforeach;
// join and output links with separator
echo join($links );
endforeach;
?>
这就是我想要的答案谢谢你的回复