[wp-hackers] please help me to resolve this error (theme changing problem)

Khaleel Abdul Karim webmaster887 at gmail.com
Fri Apr 23 15:57:23 UTC 2010

Below listing contains a plugin which i have written.. the task of this
plugin is to allow publisher to select a theme while posting a page and the
page (only the page ) will be displayed in the selected theme . But i'm not
getting the complete functionality. I got the styles changed but the page
template is still not changing . I found this feature in heaspace2 plugin
and themeswitcher. but i'm trying to develop my own simple plugin. As i'm
new to wordpress i could not solve this from the past 3 days . Please anyone
help me to fix this ..

Plugin Name: ThemeSelect_OOPS_NEw
Plugin URI:
Description: This will allow admin chose a theme for a new page
Version: 0.0.1
Author URI:
License: GPL
class ThemeSelect
    function ThemeSelect()
        add_filter('template', array(&$this,'get_post_template'),1);
        add_filter('stylesheet', array(&$this,'get_post_stylesheet'),1);
    function add_theme_box() /* Adds a custom field to set theme */
    if( function_exists( 'add_meta_box' ))
        add_meta_box( 'theme', 'Select Theme',
'show_theme_selector','page','normal', 'high');
    function show_theme_selector($post)  /* Loads the select menu for the
theme selector*/
        echo "<select name=\"thm\">";
        foreach($themes as $theme)
        { ?>
            <option value="<?php echo $theme['Name']; ?>" <?php
if($default_theme==$theme['Name']) echo "selected=\"selected\""; ?>> <?php
echo $theme['Title']; ?> </option>
    <?php   }
        echo "</select>";
    function save_theme($postid)
            $themedata = $_POST['thm'];
            //if(get_post_meta($postid,'theme', true)=="")
            //    add_post_meta($postid,'theme',$themedata);
        //    else
        //    {
        //    }

function get_post_template($template='')
    global $post;
    $sel_theme = get_post_meta($post->ID, 'theme', true);
        $template = stripslashes($theme['Template']);
    return $template;

 function get_post_stylesheet($stylesheet='')
     global $post;
     $sel_theme = get_post_meta($post->ID, 'theme', true);
         $stylesheet = stripslashes($theme['Stylesheet']);
     return $stylesheet;
$theme_select=new ThemeSelect();


Khaleel Abdul Karim

More information about the wp-hackers mailing list