Auto get_header and get_footer on every template?

Looking at wp-includes/template-loader.php … there seems to be a way:

if ( $template = apply_filters( 'template_include', $template ) )
    include( $template );

You could hook into that filter, handle the including in a callback function and return FALSE.

Sample code, not tested:

add_filter( 'template_include', function( $template ) {

    get_header();
    include $template;
    get_footer();

    return FALSE;
});

Leave a Comment