Support » Fixing WordPress » no display No categories result from wp_list_categories

  • Hi everyone πŸ˜‰

    I try to not have a result like “No categories” from the wp_list_categories function. How can we display nothing if there’s no categories ?

    Anyone have a solution ?

    Best regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter tprod

    (@tprod)

    Any ideas ?

    This code would do it:

    <?php
    $cats = wp_list_categories('echo=0');
    if ( !preg_match( '/No\scategories/i', $cats ) ) { echo $cats; }
    ?>

    If the displayed Text reads “No categories”.

    Jan

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘no display No categories result from wp_list_categories’ is closed to new replies.