Single Page WordPress Theme – Using page templates

Well I think I seem to be doing what I was intending too. Thanks @Milo for pointing me in the right direction! As You can see below I used the get_page_template_slug(); and str_replace() to filter through the templates used per page.

Can someone Verify that this is a viable option?

$args = array (
    'post_type'                => 'page',
    'post_parent'            => '29',
    'orderby'                => 'menu_order',
    'order'                  => 'ASC',
);

$query = new WP_Query( $args );


if ( $query->have_posts() ) {
    while ( $query->have_posts() ) {

        $query->the_post();
        $tn = get_page_template_slug( $post_id );
        $word = array("page-", ".php",' ');
        $template = str_replace($word,'',$tn);

        get_template_part('page', $template);
    }
} else {

}

Leave a Comment