最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp query - Custom order revolution sliders post base slides as inserted in Specific Posts List field

programmeradmin3浏览0评论

My homepage shows about 10-20 post that are manually selected in a slide. I have used Revolution slider. There is a field Specific Posts List field Where I have inserted post Ids 16427,16557,16822,16392,16507 and I want to show them as I have inserted on the field.

I found this Helpful in understanding but I don't want to insert a "order" custom field if possible. Another link made me understand what other option I have however don't understand post__in and menu_order.

Is there a way to show it as my custom list without using custom field?

My homepage shows about 10-20 post that are manually selected in a slide. I have used Revolution slider. There is a field Specific Posts List field Where I have inserted post Ids 16427,16557,16822,16392,16507 and I want to show them as I have inserted on the field.

I found this Helpful in understanding but I don't want to insert a "order" custom field if possible. Another link made me understand what other option I have however don't understand post__in and menu_order.

Is there a way to show it as my custom list without using custom field?

Share Improve this question asked Jan 22, 2020 at 9:40 Prakash PoudelPrakash Poudel 115 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0
function modify_slider_order($query, $slider_id) {

    if($slider_id == 4) {
       // $ids=[16427,16557,16822,16507,16392,16548,16564,16426,16412,16404,16419,16421];
         $query['orderby'] = 'post__in';
//         $query['orderby'] = array (
//     'post__in' => $ids,
//     'orderby' => 'post__in',
//     'order'   => 'ASC'
// );


    }

    return $query;

}

add_filter('revslider_get_posts', 'modify_slider_order', 10, 2);

This solved my problem, I'm not sure why I don't even have to pass IDs but this worked.

发布评论

评论列表(0)

  1. 暂无评论