Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jessedmatlock/9c8732c280ffb35ba2e9d4c3edbb4c8a to your computer and use it in GitHub Desktop.

Select an option

Save jessedmatlock/9c8732c280ffb35ba2e9d4c3edbb4c8a to your computer and use it in GitHub Desktop.

Revisions

  1. @kisabelle kisabelle created this gist Jan 22, 2014.
    17 changes: 17 additions & 0 deletions wp-child-page-template.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    There is no specific template for child pages, but you can do this pretty easily with the get_template_part() function.

    First create a file called "content-child.php".

    Second create a file called "content.php".

    Next, inside of page.php, place this:

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

    Anything that you want displayed on a child page will be placed inside of content-child.php. Anything you want displayed on non-child pages will be placed in content.php.