E
E
Evgeniy2021-08-04 01:29:08
WordPress
Evgeniy, 2021-08-04 01:29:08

How to find out which pages are using a particular WordPress template?

Good afternoon, tell me please

Is it possible to find out which pages use custom templates in WordPress?
Specifically, which pages use for example page1.php and which page2.php ?

A project has appeared where there is a lot of confusion with them, you correct on one page and others fly.
I would like to know in advance where to look / check after edits
I know about the Show Current Template plugin, but this is not it .. Somehow a list if you can display it, it will be cool

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem Zolin, 2021-08-04
@Zheleznov

In the meta_value, specify the template you are looking for, where $page->post_title displays a list of page titles with this template

$pages = get_pages( [
  'meta_key'     => '_wp_page_template',
  'meta_value'   => 'page-tpl.php',
  'hierarchical' => 0
] );

foreach( $pages as $page ) {
  echo '<p>' . $page->post_title .'</p>';
}

G
Gucciprado1337, 2021-08-04
@Gucciprado1337

Just in the Page's tab in WP, go to Pages, and there will be templates, well, you most likely have a problem in the same page1.php that is located in your WP theme directory

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question