pixelbrad
10/25/2017 - 9:36 PM

WP Child-page template

There is no specific template for child pages, but this can be done pretty easily with the get_template_part() function.

Credit: https://wordpress.stackexchange.com/questions/55301/is-there-a-default-template-file-for-child-pages-subpages

<?php

/* 
 * There is no specific template for child pages, but it can be implemented easily with
 * get_template_part().
 *
 * 1. Create a file named "content-child.php"
 * 2. Create a file named "content.php"
 * 3. Use the following code below to grab the appropriate template
 */

if( $post->post_parent !== 0 ) {
    get_template_part('content', 'child');
} else {
    get_template_part('content');
}
?>