Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

maybe you can help: Bellow there is a simple code listing my blogs categories. I need some code that will not display the *ul is there aren't any categories to display*

<ul>
<li><p>Categories:</p></li>
<? $master_cat = get_category_by_slug('Master');
   $master_cat_id = $master_cat->term_id; 
   $slave_cat = get_category_by_slug('Slave');
   $slave_cat_id = $slave_cat->term_id;
   wp_list_categories('orderby=name&title_li=&exclude='.$master_cat_id.','.$slave_cat_id.''); ?>
</ul>

Ty very much

share|improve this question
1  

1 Answer

up vote 1 down vote accepted
<?php
$master_cat = get_category_by_slug( 'Master' );
$master_cat_id = $master_cat->term_id; 
$slave_cat = get_category_by_slug( 'Slave' );
$slave_cat_id = $slave_cat->term_id;
$categories = wp_list_categories( 'echo=0&show_option_none=&orderby=name&title_li=&exclude='.$master_cat_id.','.$slave_cat_id );
if ( $categories ) : ?>
    <ul>
        <li><p>Categories:</p></li>
        <?php echo $categories ?>
    </ul>
<?php endif; ?>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.