• Hi my name is Leandro i’m Brazilian

    when i was trying to use the function wp_list_categories()
    i see that return the categories using

    • elements.

      But in this shape <li class=”cat-item cat-item-27″>
      returning a class but not an id and one diferent value of class per category.

      To resolve this problem i change the function start_el() on classes.php

      Change the last if on function start_el()

      [Code moderated as per the Forum Rules. Please use the pastebin]

      Making this changes the out put of functions will be: <li class=”cat-item” id=”cat-item-27″>

      this way will be more easerly to use css XD

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter heitarosd

    (@heitarosd)

    I finishe now the test on version 2.9.2
    and run normaly

    Hello Heitarosd,

    I know this is not an issue, but you can achieve the same thing without hacking WordPress. Just put the next code to your theme functions.php :

    class custom_walker_category extends Walker_Category {
    	// Copy here your functions you want to override (like your hacked start_el function)
    }
    function custom_list_categories($args = array() ) {
    	$args = wp_parse_args( $args );
    	$args['walker'] = new custom_walker_category;
    	wp_list_categories( $args );
    }

    And then replace in your templates :

    wp_list_categories('yourargs...');

    by :

    custom_list_categories('yourargs...');

    Hope this helps.

    Mathieu at IRCF.

    Hi Ircf, Your code looks very interesting and potentially useful. I too edited the function start_el(), in my classes.php and am trying to get it into my funtions.php. Right now the only way I can do it is to erase the entire class and move it to functions.

    Your code looked helpful, but I wasn’t able to apply it successfully.

    My edit puts the number in front of the category.

    my edited function is:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Then I style it using my style.css

    I figured out the syntax… here is the correct code for applying it to the template…

    https://wordpress.pastebin.com/prhxbL1S

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘classes.php and wp_list_categories()’ is closed to new replies.