Forked from yoren/1fix-switch-theme-on-certain-pages.php
Created
September 28, 2016 01:14
-
-
Save tzkmx/2e12d203a5856bbf4c57fb5bcc7b1224 to your computer and use it in GitHub Desktop.
WordPress tiny plugin - Switch theme on certain pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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