Create a Featured Posts Slider

Create a post-based slider populated with your blog's sticky posts!

Table of Content

  • Step 1 : Setup a post-based slider
  • Step 2 : Add code to functions.php
  • Step 3 : Prepare posts

Step 1:

Setup your post-based slider with some default options.

Leave the category/tag selections empty to pull in all Stick Posts. Or select some categories/tags to restrict Sticky Posts to those selections.

Step 2:

Add the following code to your theme’s “functions.php” file.

function slider_sticky_posts($query, $slider_id) {
 
    // only apply the special filter for slider with "x" ID
    // http://prntscr.com/r3ovyu
    if($slider_id == 4) {
 
        // only include "sticky" posts
        $query['post__in'] = get_option( 'sticky_posts' );
 
    }
 
    return $query;
 
}
 
add_filter('revslider_get_posts', 'slider_sticky_posts', 10, 2); 

Step 3:

Choose which posts will be pulled into the slider

Visit one of your posts, and select “Edit” from the “Publish -> Visibility” section.

Then choose “Stick this post to the front-page” to tag the post as a “Sticky”.

Quick Note

Unless your website is setup to display posts on its homepage, designating a post as a “Sticky” like this will not effect your current homepage content .

Create a Featured Posts Slider

The Author

KC

Strength does not come from winning. Your struggles develop your strengths. When you go through hardships and decide not to surrender, that is strength.

Liked this Post?
Please Share it!