I´m displaying a menu with this code:
<!-- Subcategory menu from current category -->
<ul class="sub-menu">
<?php
if (is_home()) {
wp_list_categories('orderby=id&title_li=&depth=1');
}
else{
$category = get_the_category();
$cat_term_id = $category[0]->term_id;
$cat_category_parent = $category[0]->category_parent;
$listcat = wp_list_categories('echo=0&child_of='.$cat_category_parent.'&title_li=&orderby=order&order=ASC');
$listcat = str_replace("cat-item-".$cat_term_id, "cat-item-".$cat_term_id." current-cat", $listcat);
if ( in_category( $cat_term_id ) || post_is_in_descendant_category( $cat_term_id )) {
echo $listcat;
}
}
?>
and each li of that menu display post titles using this:
<!-- Post list from current category -->
<div class="menu_list">
<ul id="submenu_productos" class="clearfix">
<?php
$IDOutsideLoop = $post->ID;
while( have_posts() ) {
the_post();
foreach( ( get_the_category() ) as $category )
$my_query = new WP_Query('category_name=' . $category->category_nicename . '&orderby=date&order=DESC&showposts=100');
if( $my_query ) {
while ( $my_query->have_posts() ) {
$my_query->the_post(); ?>
<!-- this line to hightlight current post in the category page -->
<li<?php if ( $post->ID == $wp_query->post->ID ) { echo ' class="test"'; } else {} ?>>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
<?php
}
}
}
?>
</ul>
</div>
The menu works well and it shows like this:

The problem is that when I have one post that belongs to that category/subcategory it is also displayed on the list… I want to hide it when it´s only one item:

Is there any way to hide it when the subcategory has only one post?
PD: PLEASE avoid telling me to put this on wordpress.stackexchange.com, I always post there with no answer and here people always help me…
You can count the number of item in your sub menu using :
I’ll suggest to add it in your if condition:
That should work