Page Themes
Assign a specific WordPress theme to any post or page.
Installation
Currently, the easiest way to install this plugin is by means of the excellent GitHub Updater. If you don’t already have it installed, download GitHub Updater’s latest released version, and install it using Plugins > Add New > Upload Plugin.
Then head over to Settings > GitHub Updater > Install Plugin, and fill out https://github.com/janboddez/page-themes
in the plugin URI field before hitting Install Plugin.
Page Themes itself requires no configuration at all.
Usage Instructions
After the plugin’s been activated, the Edit screen for posts and pages will show a Page Theme meta box. Select a theme, publish or update the post (or page), and … that’s about it.
Menus, Widgets, and More
You may want to temporarily activate (e.g., on a staging site) each theme to properly set up menus and widgets.
Using WordPress’s Customizer
The Customizer, unfortunately, won’t help much here. Viewing a page in the Customizer, you should see the theme options for that page’s theme, but the menu and widget locations will probably be those of the overall site theme. (This won’t be fixed anytime soon ever.)
Note that (using WP-CLI, for example) you can copy theme settings to, e.g., child themes. Like, you could set up your overall site, then assign a child theme to a specific page, copy over the parent theme’s options (think widgets, and menus), and then start customizing (like, assigning a different layout or color scheme to said page). No need to temporarily mess up your entire site.
Custom Post Types
As WordPress sets up the active theme (the thing we are overriding) before most plugins define their Custom Post Types, there is no out-of-the-box support for them.
Note: If you are in control of Custom Post Types and happen to register them at setup_theme
, rather than init
, this plugin can be made to work with them via the page_themes_post_types
filter.
Filter Hooks
page_themes_post_types
Use this filter to show the Page Theme meta box for post types other than “post” and “page.” (Note the earlier remark on Custom Post Type support being very, very limited!)
add_filter( 'page_themes_post_types', function( $post_types ) {
// Supported post types.
return array(
'post',
'page',
'my-custom-post-type',
);
} );
page_themes_current_url
Page Themes uses WordPress’s built-in url_to_postid()
to figure out which theme to load. The URL it’s fed can be filtered like so:
add_filter( 'page_themes_current_url', function( $current_url ) {
// Do something.
return $current_url;
} );
Gutenberg
This plugin uses WordPress’s Meta Box API—supported by Gutenberg—to store per-post theme settings, which makes it 100% compatible with the new block editor.