• Resolved erniegarcia

    (@erniegarcia)


    I’m in the process of setting up a new WordPress theme entitled Habitat. My current setup is active on the link below:

    http://tinyurl.com/682k3tc

    I would like to configure my “post count” for Categories and Archives to display inline with each respective category, however it appears below in a new line all to itself. Is there a way to correct this issue?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter erniegarcia

    (@erniegarcia)

    If someone can help me with this issue, it would be very much appreciated.

    it is caused by some style for the category links with ‘display: block;’

    which you may want to keep because it is for the styling of the whole line background.

    you could add a filter function to functions.php of your theme, to ‘pull’ the category count numbers into the link:

    add_filter('wp_list_categories', 'cat_count_inline');
    function cat_count_inline($links) {
    $links = str_replace('</a> (', ' (', $links);
    $links = str_replace(')', ')</a>', $links);
    return $links;
    }

    obvious change – the numbers in the brackets are now part of the link – and should be on the same line.

    Thread Starter erniegarcia

    (@erniegarcia)

    Hi alchymyth. Thank you for the info. Your suggestion works for the categories section. Any idea how I would do that for the archives section as well?

    try to add this filter code to functions.php of your theme:

    add_filter('get_archives_link', 'archive_count_inline');
    function archive_count_inline($links) {
    $links = str_replace('</a>&nbsp;(', ' (', $links);
    $links = str_replace(')', ')</a>', $links);
    return $links;
    }
    Thread Starter erniegarcia

    (@erniegarcia)

    That did the trick! Thank you so much alchymyth. 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Category & Post Count On One Line’ is closed to new replies.