Used this somewhere??? It lists all pages having a Page Template of the same value as the current page’s Template
<?php
$meta_key = '_wp_page_template';
$template = $wpdb->get_var( $wpdb->prepare("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = %d AND post_id = %s", $meta_key, $post->ID) );
$template_pages = $wpdb->get_col( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %d AND meta_value = %s", $meta_key, $template) );
wp_list_pages('include=' .implode(",", $template_pages));
?>
Just set $template to the value of the Page Template you are looking for…
great thanks i will try it
Michael,
I tried to use this code, but it still lists all of the pages for the site , not just from the included template.
Hmm, thought I tested that, but I had a problem, so try this in your Page Template
<?php
$meta_key = '_wp_page_template';
$template = $wpdb->get_var( $wpdb->prepare("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = %s AND post_id = %d", $meta_key, $post->ID) );
$template_pages = $wpdb->get_col( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s", $meta_key, $template) );
wp_list_pages('include=' .implode(",", $template_pages));
?>