Skip to content

Snippet: Display A Post Slider Anywhere

function my_category_slider( $slider ) {

    // Display the "test" revolution on category archives
    if ( is_category() ) {
        $slider = '[rev_slider alias="test"]';
    }

    // Return specific slider for all pages if $slider not defined already
    if ( is_page() && ! $slider ) {
        $slider = 'YOUR SLIDER SHORTCODE';
    }

    // Return slider
    return $slider;
    
}
add_filter( 'wpex_post_slider_shortcode', 'my_category_slider' );
All PHP snippets should be added via child theme's functions.php file or via a plugin. We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top