I have a nested list of a particular taxonomy but it only shows the taxonomy names. I want to actually show the list of posts for that custom post type for that taxonomy. Do I need to use WP_Query to get the posts or what is the best way to achieve this?

$categories = get_terms( 'my-taxonomy', array(
'hide_empty' => 0,
) );

$subcategories = $subsubcategories = $categories;

foreach ( $categories as $category ) {
// Only top level terms
if ( 0 != $category->parent ) {

// It is first level, display it
echo '<h2>' . $category->name . '</h2>';
echo '<ul>';

foreach ( $subcategories as $subcategory ) {
// Only child terms
if ( $category->term_id != $subcategory->parent )...

This is only a snippet of a WordPress Website Design Article written by user10980228

Read Full Article

Content Disclaimer 

This Content is Generated from RSS Feeds, if your content is featured and you would like to be removed, please Contact Us With your website address and name of site you wish to be removed from.


You can control what content is distributed in your RSS Feed by using your Website Editor.

Tech Shop Offers