How To Use A Page Template Anywhere In WordPress Using Template Include

Using the template_include function included in WordPress, paste this code in your child themes functions.php file and modify accordingly.

add_filter( 'template_include', 'front_page_landing_template', 99 );

function front_page_landing_template( $template ) {

if ( is_front_page()  ) {
$new_template = locate_template( array( 'page_landing.php' ) );
if ( '' != $new_template ) {
return $new_template ;
        }
    }

return $template;
}

The function only works with page templates and doesn’t work for archive or other template files.

Using Custom Post Type Archives Anywhere

One response to “How To Use A Page Template Anywhere In WordPress Using Template Include”

  1. […] Use Any Template Anywhere in Your WordPress Theme […]

Was This Tutorial Helpful?

Free

$0

Access only to all free tutorials per month.



Monthly

$75

Access to 10 premium tutorials per month.


Tutorial Request


Includes code guarantee and coding support.

Yearly

$500

Access to 15 premium tutorials per month.


Monthly Tutorial Request


Includes code guarantee and priority coding support.