Is there a way to query WordPress pages that have certain template?
Here’s what I got, but doesn’t show anything:
<?php $my_query = new WP_Query(array( 'meta_key' => '_wp_page_template', 'meta_value' => 'template-city.php' )); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<li>
<?php the_title(); ?>
</li>
<?php endwhile; ?>
Of course, there is page template file named template-city.php
if
post_type
is left out WP will look for post, and you are looking for pages.