Answer the question
In order to leave comments, you need to log in
Displaying WordPress subcategories, how to hide an empty block when there are none?
Good day!
The essence of the question is in the title...
Tell me please, I just can't figure it out myself... I'm not strong in php...
I'm on the category page, I display subcategories with the code:
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Подкатегории</h3>
</div>
<div class="panel-body">
<ul class="list-inline">
<?php if (count(get_categories('child_of='.$cat))) //Если в текущей категории нет подрубрик, не отображаем... ?>
<?php if (is_category()) { ?>
<?php $current_cat=get_query_var('cat'); //если ее убрать, то будет выводиться весь список рубрик стайта
wp_list_categories('child_of='.$current_cat.'&title_li=&show_count=1');} ?>
</ul>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
line
<?php if (count(get_categories('child_of='.$cat))) : ?>
<?php endif;?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question