Title: Programmatically change Carousel Items order
Last modified: February 28, 2024

---

# Programmatically change Carousel Items order

 *  [charlie67p](https://wordpress.org/support/users/charlie67p/)
 * (@charlie67p)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/programmatically-change-carousel-items-order/)
 * Hi,
   On my Homepage there is a CBB carousel “partners” with 10 items.Once per 
   month the order of the items should change. (so that in the end of the year each
   item/partner has been in the First position at least during 1 month)Is it possible
   to programmatically change Carousel Items order?Do you have any idea about how
   to achieve that ?An other way would be to randomize the items order every time
   the page is loaded. (but maybe it is a bad idea for the performances… and not
   sure that it would work with a cache/CDN…)Thank you
    -  This topic was modified 2 years, 3 months ago by [charlie67p](https://wordpress.org/support/users/charlie67p/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Phi Phan](https://wordpress.org/support/users/mr2p/)
 * (@mr2p)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/programmatically-change-carousel-items-order/#post-17461479)
 * Hi Charlie,
 * Yes, there are some ways to achieve your requirement.
 * The easiest way is, as you mentioned, using random order for the query. If your
   site doesn’t have thousands of posts, then performance is not an issue. For caching/
   CDN, you can set the expiry time to around 1 or 2 weeks.
 * Another approach is to use a custom field like ACF Relationship field to store
   carousel posts. Then you can query posts from that custom field. You can manually
   change the order of the posts or create a cron job to do it automatically.
 * To query the posts, you can use a similar code snippet from your old thread [https://wordpress.org/support/topic/get-current-post-id-and-use-it-in-meta-query-builder/](https://wordpress.org/support/topic/get-current-post-id-and-use-it-in-meta-query-builder/).
 * Alternatively, my other plugin MFB Pro can query posts from a custom field. I
   recorded a video guide for it [here](https://metafieldblock.com/docs/query-fields.mp4).
 * Phi.
 *  Thread Starter [charlie67p](https://wordpress.org/support/users/charlie67p/)
 * (@charlie67p)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/programmatically-change-carousel-items-order/#post-17473354)
 * Hi!
   Thanks you for your suggestions ! (Sorry that I did not answer earlier)I 
   will try it as soon as I canRegards

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Programmatically change Carousel Items order’ is closed to new replies.

 * ![](https://ps.w.org/content-blocks-builder/assets/icon.svg?rev=2605258)
 * [Content Blocks Builder - Create blocks, repeater blocks with carousel, grid, popup layouts](https://wordpress.org/plugins/content-blocks-builder/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/content-blocks-builder/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/content-blocks-builder/)
 * [Active Topics](https://wordpress.org/support/plugin/content-blocks-builder/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/content-blocks-builder/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/content-blocks-builder/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [charlie67p](https://wordpress.org/support/users/charlie67p/)
 * Last activity: [2 years, 3 months ago](https://wordpress.org/support/topic/programmatically-change-carousel-items-order/#post-17473354)
 * Status: not a support question