One section of my website is going to be completely different visually than the rest of the pages, is there a way to apply a WP Theme to specific page templates ?

1 Answer
1

In fact there is, using template_redirect, which you would put in the functions.php file – Here’s what I use:

function uniquename_default_template() {
    if(get_post_type() == 'posttype') : /* You could use is_single() instead of get_post_type() == '' or any type of conditional tag) */
    include(TEMPLATEDIR . 'path/to/theme/file.php'); /* You could use TEMPLATEDIR to get a file from a template folder, or PLUGINDIR to get a file from the plugins directory - doesn't support HTTP requests */
    exit; endif;
}
add_action('template_redirect', 'uniquename_default_template');

The above code checks for a post_type called posttype, if it is, it will include the PHP file specified in the include statement by redirecting the template using the template_redirect function.

Leave a Reply

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