I was able to figure this out and make it dynamic.
I created a variable $template
that I put inside the loop, in which I stored the page template.
$template = get_post_meta( $post->ID, '_wp_page_template', true );
Then, I utilize this where I need the child pages to show up.
<?php include(locate_template($template)); ?>
This is working for me and is pulling each child page into the parent page according to their chosen page template. Here, for your enjoyment is the entirety of the code.
<?php
$this_page=get_query_var('page_id');
$loop = new WP_Query( array('post_type'=>'page', 'posts_per_page' => -1, 'post_parent' => $this_page, 'orderby' => 'menu_order', 'order' => 'ASC') );
while ( $loop->have_posts() ) : $loop->the_post();
<?php include(locate_template($template)); ?>
<?php endwhile; endif; ?>
Related Posts:
- Single Page WordPress Theme – Using page templates
- Some doubts about how to show posts in a custom theme?
- get_template_part vs action hooks in themes
- Grab the first paragraph of each post
- First post of each category
- Echo all category names, apart from one
- how to get the post attachement image in full size?
- Change image size depending on page
- How can I use the WordPress Loop and Pagination in multiple instances but different scenarios throughout my site?
- first excerpt fine, subsequent post excerpts shift to the right instead of displaying vertically [closed]
- List categories of a post hierarchically?
- Local variable name in setup_postdata()
- How get the 10 most viewed pages (not post)
- How to close open divs in post loop
- Why am I getting posts back when I shouldnt
- Meaning of “if ( is_home() && ! is_front_page() )” snippet?
- The the_post_thumbnail without srcset?
- after_setup_theme always runs
- WordPress API Menu/Submenu Order
- What WP folder can I use to write files to?
- Get 10 posts from a WP_Query. If less than 10, get the remainder from elsewhere
- Why I can’t add a CSS style in this WordPress theme?
- register_sidebar ignores ‘id’ and ‘class’
- Display a different theme for not logged-in users
- Best practice (forward compatibility) for theme options
- Add colors to existing color palette without replacing it
- A two column loop with one lead post
- Returning Variables back into a template
- new theme permissions don’t allow me to edit
- Getting Permalink within the loop
- Which theme foundry has clean coded themes, where code is poetry [closed]
- What page should I use for a contact form?
- Retrieve data using wpdb to use for customizer controls
- How can a Theme Contain no Header File or Footer File?
- Cannot get full thumbnail size using the_post_thumbnail
- How WordPress converts URL to $query_string
- Version control for both Vagrant config and themes being developed [closed]
- Is there a way to activate different theme for specified users? [closed]
- how can I remove the sidebar from my wp homepage [closed]
- Does any theme support child theme?
- How do I save a wordpress theme’s files and install them on another site?
- “add_theme_support” for custom footer color?
- show a post from a specific post format
- How to add infinite scroll?
- get_option in header.php not returning value from customizer
- Internal error 500 accessing Theme > Customize
- Theme Development: Starter Content after hook
- Change locale by detecting viewer’s browser language setting and let them choose prefered language after
- Why is it needed to enqueue parent stylesheet in child theme?
- Is there any WordPress theme for Self Storagae just like Spacer [closed]
- Customizer: save setting/control content to post/page
- WordPress Unite Theme: Footer isn’t sticking [closed]
- Is accessing theme and using customizer GPL distribution?
- How to enqueue javascript for WP Customize options sidebar?
- WordPress 500 Internal server error when activating custom theme [closed]
- Customize how a WordPress theme looks like in the Theme Selector
- How to set a page as homepage in stead of the newspages?
- Widget Option is Missing
- WordPress Theme Validator?
- Get the amount of posts on a given page
- If you were to start using a WordPress framework today, which one would you use? [closed]
- Template for landing pages
- Is it possible to have a theme that uses only one single page?
- underscores use of the article element on the page template
- Plugin does not work in custom theme
- html5-reset theme does not show the image [closed]
- What exactly is “wordpress theming”? [closed]
- Previous and Next links not populating, have I missed something?
- Valid SQL query not returning results
- Is there a way to retrieve the calling template part?
- WP_Query not getting all posts, just tagged posts
- Change Image Sizes for Mobile Theme
- Recommended sidebar / content widths
- Converting a theme to a child theme in a network
- What is the difference between Twenty eleven & roots framework?
- Is there a list of default generated Gutenberg block CSS? Unable to align video blocks
- How to change listing type permlink?
- Adding popup support to the theme
- Calling a WP Plugin Function’s Variable in Theme Template [duplicate]
- How to make updatable custom WordPress theme?
- How can I access variables from theme in child theme? [closed]
- Creating a Single Page Theme correctly
- Is it possible to echo a woocommerce prouct attribute discription?
- Child theme menu not appearing in Twenty Seventeen
- How do I remove header/page-title image in farvis theme? [closed]
- How to link post image to post link?
- WordPress Twenty-Fourteen: How to Remove Home Page Header Image from Other Pages
- On wordpress, how do i require specific dimensions from user uploads only
- WordPress Theme Developments – Start from another theme
- Slider should be display in home template [closed]
- Modify comments_popup_link output
- Can you create a custom page with content in the center already defined?
- How to migrate the menu from the site on my own theme in WordPress?
- RSS feed url showing page not found. How to solve it?
- How to convert that page to a wordpress template? [closed]
- Toolbox theme using printif statement – help needed understanding code block
- php file child theme directory not overriding parent theme php file [duplicate]
- How to Create a Multi Purpose Theme?
- Display Page featured Image as well as Posts featured Image
- Custom Single Page Portfolio Theme [closed]