[ad_1]
Try this one:
function custom_add_count_on_archive_title( $title ) {
$term = get_queried_object();
if( $term instanceof WP_Term && 'category' === $term->taxonomy ) {
$title .= ' ('.$term->count.')';
}
return $title;
}
add_filter( 'get_the_archive_title', 'custom_add_count_on_archive_title', 10, 1 );Add this in the functions.php of your child-theme or via Code Snippet-plugin.
It works, thank you. Maybe is it possible to style the number and the parethesis by css?
Replace
$title .= ' ('.$term->count.')';with
$title .= ' <span>('.$term->count.')</span>';and you should be able to style it via CSS, e.g.:
.page-title span { color: red; }
