_wp_page_template to dynamically use template
First things first, never use query_posts, it overwrites the main query and can cause unwanted side-effects. Use WP_Query instead. _wp_page_template is a post meta key, so the first thing we need to do is to load the value stored in that key for each page, using get_post_meta. That will give us the filename, which we … Read more