Хорошо, у меня есть этот код петли:
<?php
//get all categories then display all posts in each term
$taxonomy = 'category';
$param_type = 'category__in';
$term_args=array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0,
'hierarchical' => 0
);
$terms = get_terms($taxonomy,$term_args);
if ($terms) {
foreach( $terms as $term ) {
$args=array(
"$param_type" => array($term->term_id),
'post_type' => 'products',
'post_status' => 'publish'
);
$my_query = null;
$my_query = new WP_Query($args);
if( /*$my_query->have_posts()*/ 1==1 ) { ?>
<div id="<?php echo str_replace(" ","",$term->name); ?>" class="category section">
<h3 class="categoryTitle"><?php echo $term->name;?></h3>
<?php
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div class="product">
<h3 class="productTitle"><?php the_title(); ?></h3>
<div class="description"><?php the_content(); ?></div>
</div>
<div class="clearfix"></div>
<?php
endwhile;
?>
</div>
<?php
}
}
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>
Что мне нужно сделать, если в текущей зацикленной категории есть дочерние элементы, тогда все дочерние имена будут отображаться как H2 (или как на самом деле)? Как я могу это сделать?