Forums

How to get child theme templates when loading theme via add_filter('template') (3 posts)

  1. mendezki
    Member
    Posted 3 years ago #

    I'm trying to load a child theme when on certain posts, pages or categories with the code below. It loads the child theme's css just fine, however, the child themes' template files don't load.

    If I explicitly set the child theme via the Appearance setting in WP 2.7 everything works as expected. What am I doing wrong or not doing that I should do?

    function mp_get_theme() {
    
        global $wp_query;
        $post = $wp_query->post;
        $id = $post->ID;
    
    	// should I load another theme?
    
    	if ($post->ID == 836 || $post->post_parent == 836 || (is_archive() && is_category('14')) || (is_single() && in_category('14')))
    	{
    	return 'newtheme';
    	}else{
    	return 'defaulttheme';
    	}
    }
    
    add_filter('template', 'mp_get_theme');
    add_filter('stylesheet', 'mp_get_theme');
  2. gijs
    Member
    Posted 3 years ago #

    I'm having the same problem.

    what is the most simple way to say "if in category X, set theme & stylesheet to Y"?

  3. design-is
    Member
    Posted 3 years ago #

    Wondering if anyone has had any luck with this subject?

    Cheers

Topic Closed

This topic has been closed to new replies.

About this Topic