• Fru

    (@fru)


    Hello!
    Is there any way to do this? Just like Kafkaesqui did here:
    http://wordpress.org/support/topic/90258?replies=7

    But… That was done with Pages list and I need the same with Categories.

    Will explain in a couple of words what for. I need to add to the name of the Category (just after tag) a certain number of dots and then a number. Like:

    Football……….3
    Hockey…………7

    Like this. So, I think I need to put wp_list_categories into a variable and then manipulate it with text-formating functions of PHP.
    Any help is apreciated. Thanks a lot for your attention.

Viewing 8 replies - 1 through 8 (of 8 total)
  • profdeadmeat

    (@profdeadmeat)

    I just saw the same thing for the plugin which is pretty cool Weighted Categories.

    It is using the depreciated version of this.

    I am about to put in a patch fix. There is a bug as far
    as I am concerned.

    Modify wp-includes/category-template.php

    Change wp_list_catories to end with:

    $output = apply_filters(‘list_cats’, $output);

    if ( $echo ) echo $output;

    return $output;

    INSTEAD of
    echo apply_filters(‘list_cats’, $output);

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    If you want that to actually work, you should do this:

    $output = apply_filters('list_cats', $output);
    if ( $r['echo'] ) echo $output;
    else return $output;

    Also you should add this to the $defaults array:
    'echo' => 1

    In order to make the behavior consistent. After making these you changes, you’ll be able to do this sort of thing:
    $stuff = wp_list_categories('echo=0&other_options=whatever...');
    …and get the results back in $stuff.

    I’ve modified your bug report to explain this more clearly and to try to get action taken on it. It’s a simple and obvious change that should have been there already, hopefully it’ll get pushed into 2.2.

    Yes, I’d also like to be able to do this… but without having to modify the WP core files. I’m running WP 2.2 but the behaviour is still the same. Can anyone running a more recent version confirm whether the behaviour has been fixed?

    I just ran into this problem with 2.2.2. It’s not a big deal but the documentation (http://codex.wordpress.org/Template_Tags/wp_list_categories) does say echo should be a parameter.

    ‘echo’ appeared in wp_list_categories() with 2.3.

    ‘echo’ appeared in wp_list_categories() with 2.3.

    Could you give an example of how to use it and maybe add it to the codex? I’m having trouble using it…

    http://wordpress.org/support/topic/146145?replies=5

    davidemorgan, I’ve answered your question in the other thread. Basically, you need to use a different WP function for what you’re trying to do.

    Thank you. Now I’m not feeling too stupid.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to insert ‘wp_list_categories’ into a PHP-valiable?’ is closed to new replies.