有沒有辦法查詢具有特定模板的Wordpress頁面? 這是我得到的,但不顯示任何東西: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
嗯,這將如何工作?你想達到什麼目的? – SMacFadyen
網站上有很多頁面 - 大陸,城市孩子,進一步有住宿兒童,或restoraunt兒童等每個頁面都有自己的頁面模板 - 所以我想顯示所有城市的查詢。希望這可以幫助? – jOpacic
這聽起來像你需要wp_list_pages(),http://codex.wordpress.org/Function_Reference/wp_list_pages – SMacFadyen