Forums

How to use substr with wp_list_categories? (3 posts)

  1. shod4n
    Member
    Posted 2 years ago #

    Hi, I have a problem with this ...

    I have

    <ul class="cat"> <?php
    wp_list_categories('title_li=&sort_column=name&show_count=0&show_last_updated=1&use_desc_for_title=1&exclude=5') ?> </ul>

    And I want to strip the character count of items in my category list ... say for example to 10 chars.

    Btw, I tried this (it's adapted from get_the_title character count limit)

    <?php if ( strlen(wp_list_categories()) > 10 ) { echo substr(wp_list_categories(), 0, 10)."..."; } else { wp_list_categories(); } ?>

  2. simplistik
    Member
    Posted 2 years ago #

    the echo argument in list wp_list_cateogries() would have to be set to 0 for you to be able to compare it to any thing and use it as a "variable". otherwise it'll just keep echoing instead.

  3. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    Or use get_categories and build a customised category listing.

Topic Closed

This topic has been closed to new replies.

About this Topic