# Page Number in Archive Headings

> Adds "Page 2 of 7" to archive headings on paginated pages, so visitors and search engines can tell the pages apart.

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

## Code

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

    $paged = (int) get_query_var( 'paged' );

    if ( $paged > 1 ) {
        $title .= sprintf( ' <span class="wpide-archive-page">&ndash; Page %1$d of %2$d</span>', $paged, max( $paged, (int) $wp_query->max_num_pages ) );
    }

    return $title;
}, 30 );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Page Number in Archive Headings" 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/
