Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Revolution Slider - display sticky posts first - by Arkanite */
- function revslider_sticky_posts_first($query, $slider_id) {
- // only apply the special filter for slider with "x" ID
- // http://prntscr.com/r3ovyu
- // create du duplication of the query that looks for sticky posts only
- $query_sticky = $query;
- $query_sticky['post__in'] = get_option('sticky_posts');
- $query_sticky['fields'] = 'ids';
- $query_sticky = new WP_Query($query_sticky);
- // create du duplication of the query that looks for non-sticky posts only
- $query_others = $query;
- $query_others['post__not_in'] = get_option('sticky_posts');
- $query_others['fields'] = 'ids';
- $query_others = new WP_Query($query_others);
- // merge the post ids of these two queries' retults, starting with the sticky ones
- $idz = array_merge($query_sticky->posts,$query_others->posts);
- // order the original query to look for these ids in this specific order
- $query['post__in'] = $idz;
- $query['orderby'] = 'post__in';
- $query['order'] = 'ASC';
- $query['ignore_sticky_posts'] = 0;
- $query['tax_query'] = false;
- return $query;
- }
- add_filter('revslider_get_posts', 'revslider_sticky_posts_first', 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement