webmaster887
Forum Replies Created
Viewing 3 replies - 1 through 3 (of 3 total)
-
Forum: Themes and Templates
In reply to: Different themes on different pagesheadspace2 plugin has a page specific theme feature will help.
but i’m developing a new plugin.. but have some error..
only the style not the template is loading .Any way to load the complete theme ?
below listing shows my code<?php /* Plugin Name: ThemeSelect_OOPS_NEW Plugin URI: Description: This will allow admin chose a theme for a new page Version: 0.0.1 Author: Author URI: License: GPL */ class ThemeSelect { function ThemeSelect() { add_action('admin_menu',array(&$this,'add_theme_box')); add_action('save_post',array(&$this,'save_theme')); add_filter('template', array(&$this,'get_post_template')); add_filter('stylesheet', array(&$this,'get_post_stylesheet')); } function add_theme_box() /* Adds a custom field to set theme */ { if( function_exists( 'add_meta_box' )) { add_meta_box( 'theme', 'Select Theme',array(&$this, 'show_theme_selector'),'page','normal', 'high'); } } function show_theme_selector($post) /* Loads the select menu for the theme selector*/ { $themes=get_themes(); $postid=$post->ID; if(get_post_meta($postid,'theme',true)) $default_theme=get_post_meta($postid,'theme',true); 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) { if(isset($_POST['thm'])) { $themedata = $_POST['thm']; //if(get_post_meta($postid,'theme', true)=="") //{ // add_post_meta($postid,'theme',$themedata); //} // else // { update_post_meta($postid,'theme',$themedata); // } } } function get_post_template($template='') { global $post; $sel_theme = get_post_meta($post->ID, 'theme', true); if(!empty($sel_theme)) { $theme=get_theme($sel_theme); $template = stripslashes($theme['Template']); //$template=get_theme_root()."/{$template}/page.php"; } return $template; } function get_post_stylesheet($stylesheet='') { global $post; $sel_theme = get_post_meta($post->ID, 'theme', true); if(!empty($sel_theme)) { $theme=get_theme($sel_theme); $stylesheet = stripslashes($theme['Stylesheet']); } return $stylesheet; } } $theme_select=new ThemeSelect(); ?>Forum: Themes and Templates
In reply to: Category Specific Themethe plugin is not working fine .. i have developed a similar plugin page specific theme has the same problem .. can anyone help to find whats wrong ?
see below listing for my plugin code<?php /* Plugin Name: ThemeSelect_OOPS_NEW Plugin URI: Description: This will allow admin chose a theme for a new page Version: 0.0.1 Author: Author URI: License: GPL */ class ThemeSelect { function ThemeSelect() { add_action('admin_menu',array(&$this,'add_theme_box')); add_action('save_post',array(&$this,'save_theme')); add_filter('template', array(&$this,'get_post_template')); add_filter('stylesheet', array(&$this,'get_post_stylesheet')); } function add_theme_box() /* Adds a custom field to set theme */ { if( function_exists( 'add_meta_box' )) { add_meta_box( 'theme', 'Select Theme',array(&$this, 'show_theme_selector'),'page','normal', 'high'); } } function show_theme_selector($post) /* Loads the select menu for the theme selector*/ { $themes=get_themes(); $postid=$post->ID; if(get_post_meta($postid,'theme',true)) $default_theme=get_post_meta($postid,'theme',true); 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) { if(isset($_POST['thm'])) { $themedata = $_POST['thm']; //if(get_post_meta($postid,'theme', true)=="") //{ // add_post_meta($postid,'theme',$themedata); //} // else // { update_post_meta($postid,'theme',$themedata); // } } } function get_post_template($template='') { global $post; $sel_theme = get_post_meta($post->ID, 'theme', true); if(!empty($sel_theme)) { $theme=get_theme($sel_theme); $template = stripslashes($theme['Template']); //$template=get_theme_root()."/{$template}/page.php"; } return $template; } function get_post_stylesheet($stylesheet='') { global $post; $sel_theme = get_post_meta($post->ID, 'theme', true); if(!empty($sel_theme)) { $theme=get_theme($sel_theme); $stylesheet = stripslashes($theme['Stylesheet']); } return $stylesheet; } } $theme_select=new ThemeSelect(); ?>Forum: Themes and Templates
In reply to: Can a different template be appliied to certain pages?I have qurstion : how can apply a custom theme for a single page? the filter template is not working .. I’m attaching the code below
<?php /* Plugin Name: ThemeSelect_OOPS_NEW Plugin URI: Description: This will allow admin chose a theme for a new page Version: 0.0.1 Author: Author URI: License: GPL */ class ThemeSelect { function ThemeSelect() { add_action('admin_menu',array(&$this,'add_theme_box')); add_action('save_post',array(&$this,'save_theme')); add_filter('template', array(&$this,'get_post_template')); add_filter('stylesheet', array(&$this,'get_post_stylesheet')); } function add_theme_box() /* Adds a custom field to set theme */ { if( function_exists( 'add_meta_box' )) { add_meta_box( 'theme', 'Select Theme',array(&$this, 'show_theme_selector'),'page','normal', 'high'); } } function show_theme_selector($post) /* Loads the select menu for the theme selector*/ { $themes=get_themes(); $postid=$post->ID; if(get_post_meta($postid,'theme',true)) $default_theme=get_post_meta($postid,'theme',true); 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) { if(isset($_POST['thm'])) { $themedata = $_POST['thm']; //if(get_post_meta($postid,'theme', true)=="") //{ // add_post_meta($postid,'theme',$themedata); //} // else // { update_post_meta($postid,'theme',$themedata); // } } } function get_post_template($template='') { global $post; $sel_theme = get_post_meta($post->ID, 'theme', true); if(!empty($sel_theme)) { $theme=get_theme($sel_theme); $template = stripslashes($theme['Template']); //$template=get_theme_root()."/{$template}/page.php"; } return $template; } function get_post_stylesheet($stylesheet='') { global $post; $sel_theme = get_post_meta($post->ID, 'theme', true); if(!empty($sel_theme)) { $theme=get_theme($sel_theme); $stylesheet = stripslashes($theme['Stylesheet']); } return $stylesheet; } } $theme_select=new ThemeSelect(); ?>Any idea?
Viewing 3 replies - 1 through 3 (of 3 total)