WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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*

<? $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.''); ?>

Ty very much

share|improve this question
up vote 1 down vote accepted
$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 ) : ?>
        <?php echo $categories ?>
<?php endif; ?>
share|improve this answer

Your Answer


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.