How to Set default page template as full width template WordPress admin.


Just add below code into your functions.php

<?php
//set default page template as full width template wordpress admin.
add_filter( "rest_prepare_page", 'set_default_page_template', 1, 2 );
add_filter( "rest_prepare_post", 'set_default_page_template', 1, 2 );

function set_default_page_template( $data, $post ) {
    if ( 0 != count( get_page_templates( $post ) ) && get_option( 'page_for_posts' ) != $post->ID && '' == $data->data['template'] ) :
        // Change path which is custom template into our theme
        $data->data['template'] = 'templates/full-width.php';  
    endif;

    return $data;
}

Leave a Comment

Your email address will not be published. Required fields are marked *