Seit ein paar Tagen quält mich ein Problem: Jetzt gebe ich es auf. Worum es geht..? Gut also der Reihe nach: Nico hat mich in den Kommentaren auf die Idee gebracht, ein Plugin zu schreiben, das für bestimmte Seiten ein anderes Theme anzeigt, als für den Rest des Blogs. Gesagt getan, relativ schnell hatte ich folgendes Gerüst:
<?php $nr_pt_themed_PP = array('page2' => 'Default', 'post5' => 'Constructor'); function nr_pt_get_theme_for($page_or_post) { global $nr_pt_themed_PP; if(array_key_exists($page_or_post, $nr_pt_themed_PP)) return $nr_pt_themed_PP[$page_or_post]; else return ''; } //Helper. Returns the option from the selected theme, or the default value, if no theme selected function nr_pt_GetOptionOrDefault($default, $option) { if(is_page() || is_single()) { global $post; $theme = nr_pt_get_theme_for($post->post_type . $post->ID); if(empty($theme)) return $default; //no filtering else { $all_themes = get_themes(); return $all_themes[$theme][$option]; } } else return $default; } function nr_pt_filter_template($template) { return nr_pt_GetOptionORDefault($template, 'Template'); } function nr_pt_filter_stylesheet($stylesheet) { return nr_pt_GetOptionORDefault($stylesheet, 'Stylesheet'); } function nr_pt_filter_template_dir($template_dir) { return nr_pt_GetOptionORDefault($template_dir, 'Template Dir'); } function nr_pt_filter_stylesheet_dir($stylesheet_dir) { return nr_pt_GetOptionORDefault($stylesheet_dir, 'Stylesheet Dir'); } //Filters add_filter('template', 'nr_pt_filter_template', 1); //1 is the priority, so this filter is the first! add_filter('stylesheet', 'nr_pt_filter_stylesheet', 1); add_filter('stylesheet_directory ', 'nr_pt_filter_stylesheet_dir', 1); add_filter('template_directory ', 'nr_pt_filter_template_dir', 1); ?>