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

WP SITES

2966

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Subscriptions
  • 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

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

Primary Sidebar

Code written by Brad Dalton specialist for Genesis & WooCommerce.

Advertise · WPEngine · Genesis · Log in

  • Account
  • Consulting
  • Post Tags
  • Contact
  • Terms
  • Monthly Membership
  • Yearly Subscriptions
  • Log in
 

Loading Comments...