Child Theme with Default Page(s) (3 posts)

  1. jw60610
    Posted 4 years ago #

    Is it possible to create a child theme that will always display a particular custom page template or templates?

    For example, let's say I wanted to create a child theme for use in a network installation that uses a particular contact us page or if it's a membership site uses a particular "about this network" page.

    This is as opposed to using the dropdown menu in the page edit screen.



  2. esmi
    Forum Moderator
    Posted 4 years ago #

    Totally and completely untested:

    function apply_my_template( ) {
       global $post;
       if (
            !current_user_can( 'edit_post', $post->ID )
            || 'page' != $post->post_type
            || wp_is_post_revision( $post->ID )
            || wp_is_post_autosave( $pos->ID )
            || 'auto-draft' == $post->post_status
            || 'trash' == $post->post_status
            return $post->ID;
        if ( $post->post_title == 'Contact' ) update_post_meta( $post->ID, '_wp_page_template',
    'page-my-template.php' );
    add_action( 'save_post', 'apply_my_template', 10, 2 );
  3. jw60610
    Posted 4 years ago #

    Thanks Esmi!

    I'll check it out. Thanks for pointing me in right direction ;)


Topic Closed

This topic has been closed to new replies.

About this Topic