Free on GitHub

Page Template Usage

See which template every page uses, and fix pages on a missing template.

Use it when

  • you switch or update a theme.
The Template column and filter on the Pages screen
The Template column and filter on the Pages screen
A page whose template no longer exists
A page whose template no longer exists
Appearance > Axle Page Template Usage
Appearance > Axle Page Template Usage

What it does

WordPress lets you pick a template for each page, but the Pages screen never shows which one. To answer "which pages use the Full Width template?" you have to open every page.

Page Template Usage adds a Template column to the Pages list and a template filter above it.

  • The column shows the template name. Click it to see every page that uses the same template.
  • The filter lists every template the theme offers, with the number of pages using each one. A count of 0 means the template is unused.
  • Click the column heading to sort pages by template.
  • Missing templates are shown in red. If you switch themes or delete a template file, pages that used it fall back to the default template without any warning. This plugin lists them so you can fix them.

Appearance > Page Template Usage shows every template on one screen: how many pages use it, which templates are unused, and which pages point at templates that no longer exist. Move every page off a template in one click, for example from a missing template to the default one, or from an old template you want to delete. Works with:

  • Classic themes (PHP page templates, including Template Post Type for posts and custom post types).
  • Block themes (custom templates from theme.json and templates created in the Site Editor).
  • Any post type that has templates.

Free and open source under the GPL. No pro version, no upsells, no ads in wp-admin, no tracking. And it stays that way.

WP-CLI

  • wp page-template-usage list (add --status=missing to see only problems)
  • wp page-template-usage reassign missing default moves every page on a missing template to the default one.

No settings and nothing stored in the database. Deactivate it and it is gone.

Install

  1. Download axle-page-template-usage.zip (v3.1.1).
  2. In wp-admin, go to Plugins > Add New Plugin > Upload Plugin and choose the zip.
  3. Click Install Now, then Activate.

Or with WP-CLI:

$ wp plugin install https://github.com/aryanjasala/axle-page-template-usage/releases/download/v3.1.1/axle-page-template-usage.zip --activate

To try it first, try.axlewp.com/axle-page-template-usage opens a private WordPress in your browser with this release and some demo content.

Compatibility

Checked by the end-to-end tests on every change. Unit tests run on PHP 7.4 to 8.4.
WordPressPHPStatus
WordPress 7.1PHP 8.3Tested
WordPress 6.9PHP 8.3Tested
WordPress 6.6PHP 7.4Tested

Questions

Why does a page show "Missing template"?

The page was saved with a template that the active theme does not provide any more. This usually happens after a theme switch, or after a template file is renamed or deleted. WordPress shows the default template for that page. Pick a new template in the editor, or in Quick Edit, to clear it.

Does it slow down the Pages screen?

No. It runs one grouped count query when the screen loads and caches the result for a minute.

Does it work on posts?

Yes, if your theme offers templates for posts. The column only appears on post types that have templates, or that have posts pointing at a template.

For developers

Every default, limit and message has a filter, and every change fires an action. The full reference, with constants, abilities and WP-CLI, is in REFERENCE.md.

axle_page_template_usage_post_typesFilter
Post types to look at. Types without templates are left out on their own ( string[] $post_types )
axle_page_template_usage_sortableFilter
Return false to turn off sorting by template, which joins postmeta and is slow on very large sites ( bool $sortable, string $post_type )
axle_page_template_usage_capabilityFilter
Who may open Appearance > Axle Page Template Usage. Default edit_pages ( string $capability )
axle_page_template_usage_can_access_post_typeFilter
Whether the current user may see and change the templates of a post type, on every screen and in every ability. Default: the capability above and edit_posts on the post type ( bool $allowed, string $post_type )
axle_page_template_usage_move_limitFilter
Items one Move click handles. Default 500 ( int $limit, string $post_type )
axle_page_template_usage_show_missing_noticeFilter
Whether the list screen warns about items on missing templates ( bool $show, string $post_type, int $missing )
axle_page_template_usage_before_reassignAction
Fires before items move, from the screen or WP-CLI ( string $post_type, string $from, string $to, int $limit )
axle_page_template_usage_reassignedAction
Fires for every batch of items moved ( string $post_type, string $from, string $to, int[] $post_ids )
axle_page_template_usage_theme_check_capabilityFilter
Who may check a theme before switching, and save or remove a plan for it. Default switch_themes ( string $capability )
axle_page_template_usage_theme_templatesFilter
Templates a theme that is not active offers, when checking it ( array $templates, string $stylesheet, string $post_type, WP_Theme $theme )
axle_page_template_usage_theme_check_sample_sizeFilter
Example items listed under each template in the check. Default 5 ( int $size )
axle_page_template_usage_theme_mappingFilter
The plan used on activation, post type => ( from => to ). missing as from means every template the theme lacks ( array $mapping, string $stylesheet )
axle_page_template_usage_switch_batch_sizeFilter
Items moved per request after a theme switch. Default 500, the rest follows in the background ( int $size, string $stylesheet )
axle_page_template_usage_apply_on_switchFilter
Return false to keep the plan and run it by hand ( bool $apply, string $stylesheet )
axle_page_template_usage_show_switch_noticeFilter
Whether the notice with the Undo shows after a switch ( bool $show, array $state )
axle_page_template_usage_mapping_savedAction
Fires after a plan is saved or cleared (empty mapping) ( string $stylesheet, array $mapping )
axle_page_template_usage_mapping_appliedAction
Fires after items moved to match a theme that was just activated, once per run ( string $stylesheet, array $state )
axle_page_template_usage_history_capFilter
Changes the history keeps, oldest dropped first. Default 10000, minimum 100 ( int $cap )
axle_page_template_usage_history_retention_daysFilter
Days an entry is kept. Default 365, 0 for no age limit ( int $days )
axle_page_template_usage_history_should_recordFilter
Return false to leave a change out of the history ( bool $record, array $entry )
axle_page_template_usage_history_recordedAction
Fires when a change is recorded, before it is written ( array $entry )
axle_page_template_usage_history_per_pageFilter
Entries per page on the History tab. Default 20 ( int $per_page )
axle_page_template_usage_history_source_labelsFilter
Names shown for the source of a change ( array $labels )
axle_page_template_usage_can_undoFilter
Last word on whether an entry may be undone ( bool $allowed, object $entry )
axle_page_template_usage_undo_limitFilter
Changes one "Undo this batch" click handles. Default 500 ( int $limit )
axle_page_template_usage_undoneAction
Fires after one change was undone ( object $entry )
axle_page_template_usage_batch_undoneAction
Fires after a batch was undone, in whole or in part ( string $batch, array $summary )

Changelog

3.1.1

  • Fix: only show the templates of post types the user can edit

3.1.0

  • New: check a theme before switching and record template history

3.0.0

  • Changed (breaking change): rename to Axle Page Template Usage for WordPress.org

Every release, with notes: GitHub releases.