Wordpress saves page templates that is assigned to a specific page in the db in the wp_postmeta
table.
These are saved as follows:
'meta_key' => '_wp_page_template',
'meta_value' => 'NAME_ OF_TEMPLATE'
With this in mind, you can loop through pages which shares a specific page template, using get_pages
(You can also make use of WP_Query
)
Example:
$pages = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => 'page-special.php'
));
foreach($pages as $page){
echo $page->ID.'<br />';
echo apply_filters( 'the_content', $page->post_content );
}
Bainternet
.