- This topic has 24 replies, 3 voices, and was last updated 3 years, 2 months ago by Matthieu.
-
AuthorPosts
-
February 24, 2021 at 6:01 pm #1671449ElvinStaffCustomer Support
I’ll try to simplify.
Hook this to
wp_head
:<link rel="stylesheet" href="owlcarousel/owl.carousel.min.css">
Hook this to
wp_footer
:
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
You then add this to the
wp_footer
as well.<script> $(document).ready(function() { $(".owl-carousel1"). owlCarousel({ loop: true, center: true, margin: 0, responsiveClass: true, nav: false, responsive: { 0: { items: 1, nav: false }, 768: { items: 2, nav: false, loop: false }, 1025: { items: 3, nav: true } } }); }); </script>
If the init script still won’t work, change all
$
characters tojQuery
. Example: From$(document)
tojQuery(document)
February 25, 2021 at 8:13 am #1672422MatthieuHello thank you for your help! Okay, I’m really having trouble understanding the integration. I have added the elements as you indicated. It still doesn’t work … I changed the $ to JQuery but it didn’t work either. Is it possible that the codes found on Codepen.io are not suitable for Generatepress / WordPress?
Thank you for the time you give me
February 25, 2021 at 4:02 pm #1672986ElvinStaffCustomer SupportIs it possible that the codes found on Codepen.io are not suitable for Generatepress / WordPress?
It should work. It’s possible that we’re justing missing things like syntaxes or empty spaces that makes the code malfunction. Or the class indicated doesn’t match.
In fact, I just spotted one.
On
$(".owl-carousel1"). owlCarousel({
, the.
andowlCarousell
has space in between. It’s possible that the space inbetween breaks the init script.February 25, 2021 at 4:10 pm #1672991MatthieuHello, unfortunately by adjusting the space between the. and owlCarousell it hasn’t changed anything .. I think I’ll drop the integration of this kind of thing, I don’t know enough about it yet …
February 25, 2021 at 5:24 pm #1673029ElvinStaffCustomer SupportYou can try another library and see if others are easier to implement. π
This has been done before by other users but I can’t exactly remember what “slider” library they used. This is definitely possible.
February 25, 2021 at 5:36 pm #1673035MatthieuYes I will see that thank you very much! Last question: For all that is hamburger menu / side panel animation effects the integration also happens in the wp_footer and the wp_head ?
Thanks π
February 25, 2021 at 6:47 pm #1673069ElvinStaffCustomer SupportIt really depends on what the library instructs you to do on its installation guide.
But in general, it’s good practice for the JS scripts to be hooked to the footer as it usually needs the whole DOM content to be loaded for it to run properly.
The CSS part of the library is usually placed on the wp_head so it loads immediately to prevent CLS.
February 25, 2021 at 6:53 pm #1673070MatthieuAh the css is usually in the wp_head part .. It’s good to know thank you, I put it in custom> additional css.
Thank you for your time! I will train myself more in the integration in php and js before I get into it … π
ThanksFebruary 25, 2021 at 7:33 pm #1673081ElvinStaffCustomer SupportNo problem. Best of luck to you in learning things. π
More tip: Add jQuery to the list as pure vanilla JavaScript may not be enough.
February 26, 2021 at 5:22 am #1673573MatthieuIt’s noted, thank you so much !
-
AuthorPosts
- You must be logged in to reply to this topic.