• 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

Load Template File Conditionally

This code loads the template file named featured.php from the child themes root directory.

You can use the code in your child themes functions.php file to load any type of template file conditionally.

In this case it uses the is_singular('page') conditional tag to load the template file named featured.php on all single pages.

Load Single Post Template On Single Pages

If you want to use a single.php post template on single pages you can add a template header to the file like this :

/**
 * Template Name: Single Page Template
 */

This enables you to choose the Single Page Template from the Templates drop down menu in the Page Attributes box on any single page.

Reader Interactions

Comments

  1. Collins Agbonghama says

    January 22, 2018 at 7:42 am

    Thanks Brad for all the code snippets you share. Glad to have found your site via Google.

    Log in to Reply
    • Brad Dalton says

      January 22, 2018 at 7:46 am

      You’re welcome Collins

      Log in to Reply

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