WordPress.org

Forums

Switching Themes using conditionals (1 post)

  1. Cristiano
    Member
    Posted 3 years ago #

    Hi WP friends,

    I´m trying to make a simple plugin to help me to show up a diferent theme for by blog posts then the rest of the website.

    After search a lot, I found some filters used to do it. But I can´t get it to work well... this is the code of the plugin:

    add_filter('template', 'the_parent_theme_directory');
    add_filter('option_template', 'the_parent_theme_directory');
    add_filter('option_stylesheet', 'the_child_theme_directory');
    
    function the_child_theme_directory() {
    
    	if (is_single()) {
    		return 'child_theme1';
    	} else {
    		return 'child_theme2';
    	}
    }
    
    function the_parent_theme_directory() {
    
    	return 'parent_theme';
    }

    The problem is that when "is_single()" it just run the style.css and don´t run the functions.php of the child_theme1. But when is "else", it runs everything, css, functions, templates...

    What´s wrong? Any help?
    Thanks!!

    [No bumping, thank you.]

Topic Closed

This topic has been closed to new replies.

About this Topic