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

WP SITES

2662

Original Genesis Tutorials & 5000+ Guaranteed Code

Snippets

  • Support
  • Newsletter
  • Videos
  • Log in

Premium Member? - Request custom code

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

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