1global $wpdb;
2
3$sql = "SELECT post_title, meta_value
4 FROM $wpdb->posts a
5 JOIN $wpdb->postmeta b ON a.ID = b.post_id
6 WHERE a.post_type = 'page'
7 AND a.post_status = 'publish'
8 AND b.meta_key = '_wp_page_template'
9 ";
10
11$pages = $wpdb->get_results($sql);
12
13echo '<pre>';
14print_r($pages);
15echo '</pre>';