Theme only on a Wordpress page. Is it possible?

Asked

Viewed 4,044 times

6

Has a site in Wordpress that is with a specific theme. IE, all posts and pages are with the appearance of this theme.

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

It is possible, just on that page, to change the theme?

2 answers

3


Plugins for multiple themes

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

I didn’t use any, so I suggest you test and see if any of them will answer.

Different layouts on a theme

If you are implementing or modifying a theme, it is also possible in the same theme to create different types of layouts. Various 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, on the other you want without the menu. Good themes have different layouts for home page, contact page, etc.

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

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

2

The base code is very simple, adjust the page 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;
}

Probably, you will need to make fine adjustments because they can give 404 errors for some features of the original theme and that WP will try to search in the alternative theme, on my local system is Twentyfourteen and gives this failure:

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 else, like comments on the utluiz, one 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(); ?>
  • Thank you. I chose to do it without programming, because I needed a quick solution.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.