Repository navigation
Expand file tree
/
Copy pathpage-private-debug.php
More file actions
69 lines (64 loc) · 2.12 KB
/
Copy pathpage-private-debug.php
File metadata and controls
69 lines (64 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* This private page is a utility to show the number of pages built using a particualr template.
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package bbgRedesign
template name: Utility: Pages by Template
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" role="main">
<div class="usa-grid-full">
<?php
$templates = wp_get_theme()->get_page_templates();
echo "<h3>Default Template (should be page.php)</h3>";
$args = array(
'post_type' => 'page',
'posts_per_page' => 9999,
'meta_query' => array(
array(
'key' => '_wp_page_template',
'value' => 'default', // template name as stored in the dB
)
),
);
$custom_query = new WP_Query($args);
if ($custom_query -> have_posts()) {
echo "<ul style='margin-left:20px'>";
while ( $custom_query -> have_posts() ) {
$custom_query -> the_post();
echo "<li><a target='_blank' href='" . get_permalink(get_the_id()) . "'>".get_the_title()."</a></li>";
}
echo "</ul>";
}
wp_reset_postdata();
foreach ( $templates as $template_filename => $template_name ) {
echo "<h3>$template_name ($template_filename)</h3>";
$args = array(
'post_type' => 'page',
'posts_per_page' => 9999,
'meta_query' => array(
array(
'key' => '_wp_page_template',
'value' => $template_filename, // template name as stored in the dB
)
),
);
$custom_query = new WP_Query($args);
if ($custom_query -> have_posts()) {
echo "<ul style='margin-left:20px'>";
while ( $custom_query -> have_posts() ) {
$custom_query -> the_post();
echo "<li><a target='_blank' href='" . get_permalink(get_the_id()) . "'>".get_the_title()."</a></li>";
}
echo "</ul>";
}
wp_reset_postdata();
}
?>
</div><!-- .usa-grid-full -->
</main><!-- #main -->
</div><!-- #primary -->
<?php /*get_sidebar();*/ ?>
<?php get_footer(); ?>