WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. jw60610
    Member
    Posted 2 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.

    Thanks.

    JW

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 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
    Member
    Posted 2 years ago #

    Thanks Esmi!

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

    JW

Topic Closed

This topic has been closed to new replies.

About this Topic