25% off ProSNIPC25OFF

Show Post Count in Category and Tag Titles

Appends the post count in parentheses to category, tag, and custom taxonomy archive titles.

PHPby SnipCraft
php
<?php
add_filter( 'get_the_archive_title', 'scseed_archive_title_with_count' );
function scseed_archive_title_with_count( $title ) {
    if ( ! ( is_category() || is_tag() || is_tax() ) ) {
        return $title;
    }
    $term = get_queried_object();
    if ( $term && isset( $term->count ) ) {
        $title .= ' <span class="scseed-term-count" style="font-weight:400;opacity:.65;font-size:.85em;">('
            . (int) $term->count
            . ')</span>';
    }
    return $title;
}
#archive#category#display#post-count#taxonomy