WordPress.org

Ready to get started?Download WordPress

Forums

wp_list_cats flag (3 posts)

  1. Sephiroth
    Member
    Posted 7 years ago #

    How about adding a flag for the wp_list_cats function so that if template designers need it, the postcounts could be drawn before the closing anchor tag. :)

    Currently, I have a list item like this:

    <li><a href="http://localhost/main/category/web-design/xhtml/" title="View all posts filed under (X)HTML">(X)HTML</a> (1)
    </li>

    Yes, I'm currently designing it on localhost, but I would appreciate it if I could achieve something like this without hacking the source:

    <li><a href="http://localhost/main/category/web-design/xhtml/" title="View all posts filed under (X)HTML">(X)HTML (1)</a>
    </li>

    Thank you.

  2. Mark Jaquith
    WordPress Lead Dev
    Posted 7 years ago #

    You can use the list_cats hook plus some regex to do that switcheroo in a filter. No core modification needed.

    Untested, but something like this should work:


    function txfx_put_count_in_the_link($text) {
    return preg_replace('#</a> (([0-9]+))#', ' ($1)</a>', $text;
    }

    add_filter('list_cats', 'txfx_put_count_in_the_link');

  3. Sephiroth
    Member
    Posted 7 years ago #

    Nope, that did not work. You caused a parse error, (which I fixed btw), but when I did have it running, the count was still outside the link. :/ Thanks for trying.. I'm hoping to get a this option added as a feature. :/ Thanks anyways.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.