Created
August 10, 2016 08:27
WordPress tiny plugin - Switch theme on certain pages
This file contains 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