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.
Was This Tutorial Helpful?