Skip to content

Instantly share code, notes, and snippets.

@yoren
Created August 10, 2016 08:27
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yoren/11b6f422e9419905236b4a0dad956366 to your computer and use it in GitHub Desktop.
Save yoren/11b6f422e9419905236b4a0dad956366 to your computer and use it in GitHub Desktop.
WordPress tiny plugin - Switch theme on certain pages
<?php
/**
* @package One_Fix_Switch_Theme
* @version 1.0
*/
/*
Plugin Name: One Fix Switch Theme
Plugin URI: https://www.1fix.io
Description: Switch theme on certain pages.
Author: Yoren Chang
Version: 1.0
Author URI: https://www.1fix.io
*/
function one_fix_switch_theme() {
add_filter( 'stylesheet', 'one_fix_stylesheet' );
add_filter( 'template', 'one_fix_template' );
}
add_action( 'setup_theme', 'one_fix_switch_theme' );
function one_fix_stylesheet( $current_theme ) {
$uri = explode( '/', $_SERVER['REQUEST_URI'] );
if ( in_array( $uri[1], array( 'slug-a', 'slug-b', 'slug-c' ) ) ) {
return 'twentythirteen-child';
} else {
return $current_theme;
}
}
function one_fix_template( $current_theme ) {
$uri = explode( '/', $_SERVER['REQUEST_URI'] );
if ( in_array( $uri[1], array( 'slug-a', 'slug-b', 'slug-c' ) ) ) {
return 'twentythirteen';
} else {
return $current_theme;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment