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

WP SITES

2784

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Consultation
  • Full Access
  • Log in

template_include

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

add_filter( 'template_include', 'single_page_template', 99 );
function single_page_template( $template ) {

if ( is_singular('page') ) {
        $new_template = locate_template( array( 'single.php' ) );
        if ( '' != $new_template ) {
            return $new_template ;
        }
    }

return $template;
}

The function loads the template named single.php on all single pages. The template named single.php can be placed anywhere in your child theme folder. In this case, its placed in the root directory as seen in the following image.

You can change the conditional tag is_singular('page') and/or the file name single.php to anything else.

Note : A file named single.php will automatically load on all single posts by default.

PHP Functions

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags
 

Loading Comments...
 

You must be logged in to post a comment.