Theme only on one Wordpress page. It's possible?

6

You have a Wordpress site that has a specific theme. That is, all posts and pages look like this theme.

It turns out that I need to create a new page, and that page must have the theme different from the entire site.

Is it possible, just on that page, to change the theme?

    
asked by anonymous 15.05.2014 / 00:37

2 answers

3

Plugins for multiple themes

Without involving programming, there are at least two plugins to do this:

I did not use any, so I suggest testing and see if any of them will answer.

Different layouts in a theme

If you are implementing or modifying a theme, you can also create different layouts in one theme. Several themes allow you to choose the layout type for each page or post.

For example, on one page you do not want the side menu, the other you want without the menu. Good themes have different layouts for the home page, contact page, etc.

I believe this solution is best for most cases, unless there is a very specific need, since it is not a common thing to completely change a theme from one page to another.

It would be very extensive detailing the step-by-step to do this, but basically you need to create a PHP add file with a specific header and Wordpress will find the new layout automatically. See documentation for more details.

    
15.05.2014 / 14:09
2

The base code is very simple, adjust the page's slug and the theme name:

<?php
/**
 * Plugin Name: (SOPT) Theme for page
 */

add_filter( 'template', 'change_theme_wpse_12931' );
add_filter( 'option_template', 'change_theme_wpse_12931' );
add_filter( 'option_stylesheet', 'change_theme_wpse_12931' );

function change_theme_wpse_12931( $template = '' ) 
{
    if( is_page('test-page') ) 
        $template = 'twentyten';

    return $template;
}

You'll probably need fine tuning because you might give 404 errors for some features of the original theme and WP will try to look for the alternate theme, my local system is TwentyFourteen and gives this flaw:

  

Failed to load resource: the server responded with a status of 404 (Not Found) http://example.dev/wp-content/themes/twentyten/genericons/genericons.css

The code is this question in WordPress Developers .

Or, like comments utluiz , you can use a page template with custom header and footer, in this example the template will call the file header-test-page.php :

<?php
/**
 * Template Name: Virtual theme
 */
if( is_page('test-page') ) 
    get_header('test-page');
else
    get_header(); ?>
    
15.05.2014 / 15:10