WPIntell

Source evidence

Get Swiper instance

YMC Filter · support · 2026-06-30T15:54:00+00:00

mixedsentiment
lowseverity
0.42relevance
10replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

3 / 22 rows with source links

13.6% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

19 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
fredericv resolved
Hello, Is there a way to get Swiper instance built with Carousel Post Layout ? Swiper’s API page says : const swiper = document.querySelector('.swiper').swiper; swiper.slideNext But my console returns null for swiper : Uncaught TypeError: can't access property "swiper", document.querySelector(...) is null Thanks for your help ! PS : the search function in the WordPress.org support forum doesn’t work at all: every time I try to search, I get no results. This topic was modified 4 days, 23 hours ago by fredericv . Hi! If you want to custom initialize the Swipe, you’ll need to disable the default settings in the plugin settings and then manually initialize the swipe (Custom Swiper Settings ). https://prnt.sc/g9Of_56zkfuV This reply was modified 4 days, 21 hours ago by YMC . Hello, Thank you for your reply. Unfortunately, I’ve already tried that, and I’m having a lot of trouble getting Swiper API to work. It’s as if certain settings defined by YMC Filter in “Carousel post layout” or “Advanced query” are affecting the new Swiper instance: For example, I can’t get the pagination or navigation to appear unless I use the callback I previously used for the other layouts (“Advanced query”) Another example: when I manage to get the pagination and navigation to appear, they don’t work—they remain unclickable That’s why I’ve fallen back on the carousel predefined by YMC, and I’m trying to retrieve its instance to customize it a bit. Thank you for your help. By the way, I’m trying to make the carousel responsive. Swiper.js shows that is possible with breakspoints : breakpoints: { // when window width is >= 320px 320: { slidesPerView: 3, spaceBetween: 10, }, // when window width is >= 480px 480: { slidesPerView: 3, spaceBetween: 30, }, // when window width is >= 640px 640: { slidesPerView: 4, spaceBetween: 40, } } This works, but as I said in my previous message, some others things not 🙂 Hi! To initialize CustomMono Swiper, you’ll need to run this code: ymcHooks.addAction('ymc/grid/after_update_72', function(data, container) { new Swiper('.swiper-72', { speed: 400, spaceBetween: 100, // do something… }); }); Change the filter ID to your own! Swiper is already enabled on the selected page. You need to initialize it within the JavaScript hook (see the filter documentation: https://github.com/YMC-22/YMC-Filter ) Yes, that’s exactly what I did … but I obtained the problems described above … It’s all very strange! The thing is, when you enable the “Use “Custom Swiper Settings” option in the plugin settings, it disables the plugin’s default initialization of the Swiper carousel. In this mode, you can customize the initialization and configuration of the swipe (the plugin won’t interfere with these settings). When custom initializing Swiper, you should always use plugin hooks (ymcHooks.addAction(‘ymc/grid/after_update_ID_Filter’, function(data, container) { … }) since posts are asynchronously loaded into the post grid itself, requiring control over asynchronous loading. By the way, the “Advanced query” settings don’t affect the carousel’s operation in any way—they are just overrides of the WP_Query object query itself, that’s all! You need to carefully analyze the entire Swiper initialization chain and ensure the correct settings within the plugin. Send us a link to your website page. Unfortunately it’s a localhost website 🙁 But yes, I think like you, it’s all very strange, espacially the thing with the callback in “Advanced query”. I will investigate further, maybe I will find something, maybe not … If you think of something, let me know please 🙂 We look forward to your resolution. We’re also very interested in learning the root cause of the problem. Please let us know if you learn anything. Good luck! So I’ve fixed my problem by deleting firefox’s cache between each change within the js hook. I didn’t know that Firefox used its cache so extensively to store the state of JavaScript objects. Above all, I thought that since we’re constantly telling JavaScript when we want to trigger an action (before the page loads, after it loads, before the DOM loads, after it loads, etc.), the cache would be cleared each time… I’ve learned something new 🙂 I think this behavior must have a lot to do with Swiper.js—don’t you think? We glad that you solve your issue!

Comments

10 shown
YMC 2026-06-30T18:23:00+00:00

Hi! If you want to custom initialize the Swipe, you’ll need to disable the default settings in the plugin settings and then manually initialize the swipe (Custom Swiper Settings ). https://prnt.sc/g9Of_56zkfuV This reply was modified 4 days, 21 hours ago by YMC .

fredericv 2026-07-01T09:52:00+00:00

Hello, Thank you for your reply. Unfortunately, I’ve already tried that, and I’m having a lot of trouble getting Swiper API to work. It’s as if certain settings defined by YMC Filter in “Carousel post layout” or “Advanced query” are affecting the new Swiper instance: For example, I can’t get the pagination or navigation to appear unless I use the callback I previously used for the other layouts (“Advanced query”) Another example: when I manage to get the pagination and navigation to appear, they don’t work—they remain unclickable That’s why I’ve fallen back on the carousel predefined by YMC, and I’m trying to retrieve its instance to customize it a bit. Thank you for your help.

fredericv 2026-07-01T09:58:00+00:00

By the way, I’m trying to make the carousel responsive. Swiper.js shows that is possible with breakspoints : breakpoints: { // when window width is >= 320px 320: { slidesPerView: 3, spaceBetween: 10, }, // when window width is >= 480px 480: { slidesPerView: 3, spaceBetween: 30, }, // when window width is >= 640px 640: { slidesPerView: 4, spaceBetween: 40, } } This works, but as I said in my previous message, some others things not 🙂

YMC 2026-07-01T12:01:00+00:00

Hi! To initialize CustomMono Swiper, you’ll need to run this code: ymcHooks.addAction('ymc/grid/after_update_72', function(data, container) { new Swiper('.swiper-72', { speed: 400, spaceBetween: 100, // do something… }); }); Change the filter ID to your own! Swiper is already enabled on the selected page. You need to initialize it within the JavaScript hook (see the filter documentation: https://github.com/YMC-22/YMC-Filter )

fredericv 2026-07-01T12:42:00+00:00

Yes, that’s exactly what I did … but I obtained the problems described above …

YMC 2026-07-01T13:37:00+00:00

It’s all very strange! The thing is, when you enable the “Use “Custom Swiper Settings” option in the plugin settings, it disables the plugin’s default initialization of the Swiper carousel. In this mode, you can customize the initialization and configuration of the swipe (the plugin won’t interfere with these settings). When custom initializing Swiper, you should always use plugin hooks (ymcHooks.addAction(‘ymc/grid/after_update_ID_Filter’, function(data, container) { … }) since posts are asynchronously loaded into the post grid itself, requiring control over asynchronous loading. By the way, the “Advanced query” settings don’t affect the carousel’s operation in any way—they are just overrides of the WP_Query object query itself, that’s all! You need to carefully analyze the entire Swiper initialization chain and ensure the correct settings within the plugin. Send us a link to your website page.

fredericv 2026-07-01T13:42:00+00:00

Unfortunately it’s a localhost website 🙁 But yes, I think like you, it’s all very strange, espacially the thing with the callback in “Advanced query”. I will investigate further, maybe I will find something, maybe not … If you think of something, let me know please 🙂

YMC 2026-07-01T13:47:00+00:00

We look forward to your resolution. We’re also very interested in learning the root cause of the problem. Please let us know if you learn anything. Good luck!

fredericv 2026-07-02T16:09:00+00:00

So I’ve fixed my problem by deleting firefox’s cache between each change within the js hook. I didn’t know that Firefox used its cache so extensively to store the state of JavaScript objects. Above all, I thought that since we’re constantly telling JavaScript when we want to trigger an action (before the page loads, after it loads, before the DOM loads, after it loads, etc.), the cache would be cleared each time… I’ve learned something new 🙂 I think this behavior must have a lot to do with Swiper.js—don’t you think?

YMC 2026-07-02T16:53:00+00:00

We glad that you solve your issue!