Forums

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

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #193194
    crawling
    Participant

    Hi,

    I am using royal slider and want a unique slider on each category page , so what i did is create a custom archive.php file and placed the slider php code right under the header .
    Now the slider shows only for that category but also want the slider to show for post assigned to that particular category.

    Here you can see the slider in action
    http://unitednews.sr/category/news/
    So this slider is working for category News but is not showing for this post for example http://unitednews.sr/news/blobal-casino/
    That post is assigned to category news .

    In my function file i also added this code
    `
    add_action( ‘wp_enqueue_scripts’, ‘enqueue_royal_sliders’ );
    function enqueue_royal_sliders() {
    global $posts;

    <code>// can be also is_archive(), is_page() e.t.c.
    if(is_category(‘news’)) {
    register_new_royalslider_files(1);
    }

    }
    `

    Can anybody help me out ?

    #193197
    Senff
    Participant

    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(
        '$the_template',
        'foreach( (array) get_the_category() as $cat ) {
            if ( file_exists(TEMPLATEPATH . "/single-{$cat->slug}.php") )
            return TEMPLATEPATH . "/single-{$cat->slug}.php"; }
        return $the_template;' )
    );
    
    #193202
    crawling
    Participant

    Works as a charm , Thanks Senff

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.