• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2665

Original Genesis Tutorials & 5000+ Guaranteed Code

Snippets

  • Support
  • Newsletter
  • Videos
  • Log in

Premium Member? - Request custom code

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 ) {

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

return $template;
</code></pre>

}

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

Using Custom Post Type Archives Anywhere

  • Load template on all Single Pages In WordPress
  • Override WooCommerce archive-product.php Template File In Genesis
  • Use Portfolio Grid Style CPT Archive Page Layout On Any Archive Page

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

PHP Code

template_include

get_body_class

if else

array

class_exists

foreach

sprintf

add_action

printf

variable

Advertise · WPEngine · Genesis · Log in

  • How Premium Membership Works
  • Sign Up
  • Support
  • Subscription Details/Invoice
  • Tagged Tutorials
  • Access-Download Problems