With this code parent term page lists all the child terms and the child term page lists all of the posts in current term, and the single page lists a big flat list of terms(hierarchical).
Now,
The parent term page is fine.
When it's child term page, i want to list all child terms( not showing with this code ) + the posts in current term( showing ).
And when it's single post, i want to list the same as child term page.
$term = get_queried_object();
$tax = 'ntp_package_type';
$parents = $term->parent;
$term_id = $term->term_id;
if($parents == 0){
wp_list_categories( array (
'taxonomy' => 'ntp_package_type',
'pad_counts'=> 0,
'title_li' => '',
'child_of' => $term_id,
)
);
}
elseif (is_tax($tax, $term->name)){
$args = array(
'post_type' => 'ntp_package',
$tax => $term->name,
);
$wp_query = new WP_Query($args);
if( $wp_query->have_posts() ):
while ( $wp_query->have_posts() ) : $wp_query->the_post();
echo "<p><a href=\"".get_permalink()."\">".$post->post_title."</a></p>";
endwhile;
endif;
}
elseif (is_single()){
}
It is for a sidebar sub nav. is it a right way to do? I'd really appreciate any help.