WordPress.org

Support

Support » Requests and Feedback » wp_list_cats flag

wp_list_cats flag

  • 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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Mark Jaquith

    @markjaquith

    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');

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_list_cats flag’ is closed to new replies.
Skip to toolbar