# Post Count in Archive Titles

> Adds the number of posts to category, tag, author and date archive headings, for example "Recipes (42)".

- Type: PHP
- Runs: Run everywhere
- Category: [Archives](https://wpide.com/library/category/archive/)
- Tags: archives, titles, count
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/post-count-in-archive-title/

## Code

```php
add_filter( 'get_the_archive_title', function ( $title ) {
    global $wp_query;

    if ( ! is_archive() || is_post_type_archive() || ! $wp_query instanceof WP_Query ) {
        return $title;
    }

    return $title . ' <span class="wpide-archive-count">(' . esc_html( number_format_i18n( (int) $wp_query->found_posts ) ) . ')</span>';
}, 20 );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Post Count in Archive Titles" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
