WordPress.org

Ready to get started?Download WordPress

Forums

Adding text before each cat, in category list (3 posts)

  1. Mike
    Member
    Posted 7 years ago #

    I need a little assistance as I cannot find a solution to my problem.

    All i want to do is add:

    <span class=\"green\">»</span>

    before the output of list_cats, to give a >> bullet.

    I dont want to use css as I dont intend to have the categories as an unordered list.

    Any solutions?

    I think it may have something to do with filtering but i cannot make it function.

    Thanks

  2. OnSeduction
    Member
    Posted 7 years ago #

    Maybe you can use "recurse" as an option for that and do with with a little php.

    http://codex.wordpress.org/Template_Tags/list_cats

  3. Mike
    Member
    Posted 7 years ago #

    great idea :D

    This worked:
    $cats = list_cats(true, 'View all', 'name','asc', '', true, false, true, true, false, false,'', '0', true, '', '', '1,2,3', false);
    $cat = explode('',$cats);

    foreach ($cat as $value){
    $value = str_replace("

  4. ", "<span class=\"green\">»</span> ", "$value");
    $value = str_replace(" ", "", "$value");

    $value .='';
    echo $value;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags