$terms = get_terms([
\'taxonomy\' => array(\'Movies, Musics, Books, Games\'),
\'parent\' => 0,
\'depth\'=> 2,
\'hide_empty\' => false,
]);
$sorted_terms = [];
if ( $terms ) {
foreach ( $terms as $term ) {
$sorted_term = [
\'WP_Term\' => $term, // the global term
\'icon\' => get_field( \'logo\', $term->taxonomy . \'_\' . $term->term_id ),
\'srating\' => get_field( \'rating\', $term->taxonomy . \'_\' . $term->term_id ),
\'carrentActiveClass\' => \'\',
\'count\' => (int) wpse340250_term_count( $term, \'sikayet\' ),
// everything you will need later here
];
///// and my code continue
在上面的代码中,我可以得到不同分类法的术语。但我正在尝试获得分类学术语的子项。谁能帮帮我吗
\'parent\' => 0,
\'depth\'=> 2,
不起作用
最合适的回答,由SO网友:Sharif Mohammad Eunus 整理而成
实际上,我不确定你想用代码实现什么。我会写这样的东西来获取儿童术语
$terms = get_terms([
\'taxonomy\' => array(\'Movies, Musics, Books, Games\'),
\'parent\' => 0,
\'hide_empty\' => false,
]);
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
foreach ($terms as $term) {
$child_term = get_term_children( $term->term_id, $term->taxonomy )
//your code here
}
}