Dieses Funktion ermöglicht es, dass man für jede Kategorie eine eigene single.php anlegen. Es wird die Kategorie-ID ausgelesen und dann kann man ganz einfach eine neue single.php erstellen in folgender Form: single-kategorie-ID.php was dann so ausschaut: single-3.php - dies wäre dann das Template was für alle Artikel genutzt werden würde diese in der Kategorie 3 sind. Falls keine spezielle single.php für einen bestimme Kategorie vorhanden ist wird die Standard single.php genutzt. Das ganze am besten in die functions.php im Themefolder.
1 2 3 4 5 | <?php add_filter('single_template', create_function('$t', 'foreach( (array) get_the_category() as $cat ) { if ( file_exists(TEMPLATEPATH . "/single-{$cat->term_id}.php") ) return TEMPLATEPATH . "/single-{$cat->term_id}.php"; } return $t;' )); ?> |
Statistik: read: 4588 / today: 2 / last: 08.02.2012
//
AJAX Libraries via Google einbinden ›
2 Kommetare • Eintrag schreiben
David Hellmann →
#1 Permalink Am 11. May 2009 um 14:58 Uhr
Mark
#2 Permalink Am 15. June 2011 um 23:34 Uhr
Hallo,
Der Code scheint soweit zu funktionieren. Doch wenn ich im Backend auf “abmelden” klicke erhalte ich folgende Fehlermeldung:
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-login.php on line 354
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-login.php on line 366
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-includes/pluggable.php on line 720
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-includes/pluggable.php on line 721
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-includes/pluggable.php on line 722
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-includes/pluggable.php on line 723
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-includes/pluggable.php on line 724
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-includes/pluggable.php on line 725
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-includes/pluggable.php on line 728
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-includes/pluggable.php on line 729
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-includes/pluggable.php on line 730
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-includes/pluggable.php on line 731
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-includes/pluggable.php on line 734
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-includes/pluggable.php on line 735
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-includes/pluggable.php on line 736
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-includes/pluggable.php on line 737
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-includes/pluggable.php on line 897
Wenn ich Beiträge aktualisieren möchte erhalte ich folgende Meldung:
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/w00deec4/wp-content/themes/telegraph/functions.php:7) in /www/htdocs/w00deec4/wp-includes/pluggable.php on line 897
Was verursacht das Problem?
Dankbar für jeden Tipp!