ORIGINAL POST:
So I'm having an issue displaying the Articles that belong Subcats of a custom taxonomy.
What I'm currently forced to do with the loop below is have multiple pages: 1 for the Subcategories and 1 for the Articles that belong to that subcat.
What I want, rather, is a page that does this:
Main Category
Description of category
Subcategory 1
- Article
- Article
Subcategory 2
- Article
- Article
Here is my code:
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
$parent = get_term($term->parent, get_query_var('taxonomy') ); // get parent term
$children = get_term_children($term->term_id, get_query_var('taxonomy')); // get children
if(($parent->term_id=="") && (sizeof($children)>0)) { // no parent, has child - core main categories
$args = array(
'child_of' => $term->term_id,
'taxonomy' => $term->taxonomy,
'hide_empty' => 0,
'hierarchical' => true,
'orderby'=>'menu_order',
'depth' => 1,
'title_li' => ''
);
echo "<h4>Subcategories</h4>";
wp_list_categories( $args );
//if there are articles in the main category as well
//echo "i have NO parent, but have children";
}elseif(($parent->term_id!="" && sizeof($children)>0)) { // has parent and child - mid level cats, we dont have these yet
//echo "i have a parent, and children";
}elseif(($parent->term_id=="") && (sizeof($children)==0)){ ?>
<h5>Articles</h5> <?
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h5 id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_title(); ?></a></h5><?
endwhile;
endif;
//echo "i have NO parent and NO children";
}elseif(($parent->term_id!="") && (sizeof($children)==0)) { // has parent, no child - last branch on tree
?><h3>Articles</h3> <?
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h5 id="post-<?php the_ID(); ?>">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?php the_title(); ?></a></h5> <?
endwhile;
endif;
//echo "i have a parent, but NO children";*/
}