Skip to content

Instantly share code, notes, and snippets.

@ciaranha
Created September 12, 2018 17:22
Show Gist options
  • Save ciaranha/7dadfdf82faccaff653179913913db7b to your computer and use it in GitHub Desktop.
Save ciaranha/7dadfdf82faccaff653179913913db7b to your computer and use it in GitHub Desktop.
<?php get_header(); ?>
<div class="container-narrow mt-80">
<?php
function list_pages_for_template($template_name) {
echo '<strong>';
echo $template_name;
echo '</strong>';
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => '_wp_page_template',
'value' => $template_name
)
)
);
$the_pages = new WP_Query( $args );
if( $the_pages->have_posts() ){
while( $the_pages->have_posts() ){
$the_pages->the_post();
echo '<li>';
the_title();
echo '</li>';
}
}
wp_reset_postdata();
}
$templates = array(
'template-master.php',
'template-integrations.php',
'template-landing.php'
);
foreach($templates as $template) {
echo '<div class="mt-40">';
list_pages_for_template($template);
echo '</div>';
}
?>
</div>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment