有没有办法查询具有特定模板的 Wordpress 页面?这是我得到的,但没有显示任何内容:
<?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; ?>
当然,还有名为的页面模板文件template-city.php