The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Show Slider Only On Category Posts Reply To: Show Slider Only On Category Posts


First, create a new file based on the “standard” single.php and call it
single-news.php. This will be the template that all posts from the News category will use, so in that file, put the slider code somewhere.

Then in your functions.php file, add this code:

add_filter('single_template', create_function(
    'foreach( (array) get_the_category() as $cat ) {
        if ( file_exists(TEMPLATEPATH . "/single-{$cat->slug}.php") )
        return TEMPLATEPATH . "/single-{$cat->slug}.php"; }
    return $the_template;' )