Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter stuntboots

    (@stuntboots)

    Endlessly.

    Thread Starter stuntboots

    (@stuntboots)

    Ignore this post, an error on my behalf!

    Thread Starter stuntboots

    (@stuntboots)

    You are beautiful! Works perfectly. The only thing I didn’t do was use the prefix setup, as this was creating two files per page template. Instead, I just load the template of the page in with the post, and it seems to work exactly how I’d wanted.

    Thanks heaps for your help!

    For anyone who wants to use single files (It’s practically the same as keesiemeijer’s, with the ‘content’ parts omitted:

    <?php
    	global $wp_query;
    	// is Page a parent page
    	if ( $post->post_parent == 0 ) {
    		// on a parent page, get child pages
    		$pages = get_pages( 'hierarchical=0&parent=' . $post->ID );
    		// loop through child pages
    		foreach ( $pages as $post ){
    			setup_postdata( $post );
    			// get the template name for the child page
    			$template_name = get_post_meta( $post->ID, '_wp_page_template', true );
    			$template_name = ( 'default' == $template_name ) ? 'page.php' : $template_name;
    			// default page template_part content-page.php
    			$slug = 'page';
    			// check if the slug exists for the child page
    			if ( locate_template( basename( $template_name ) , $load, $require_once ) != '' ) {
    				$slug = pathinfo( $template_name, PATHINFO_FILENAME );
    			}
    			// load the content template for the child page
    			get_template_part( $slug );
    		}
    	}
    ?>
Viewing 3 replies - 1 through 3 (of 3 total)