Simple Review Slider / Carousel – How To Guide (and 1 Support Question)
-
I noticed other people asking about adding a slider or carousel of testimonials in the support forums, so I thought I would include my VERY simple review slider that I created, which doesn’t require much coding effort or knowledge to include on a site.
I have placed my slider in the footer of my client’s site.
————–
Here is how:
————–
First create a single review (display=1) shortcode for the reviews. Be sure to set pagination=”ajax” like this. Note that the class name is important and should be unique to your site, as this will be used by the jQuery code further below:[site_reviews class="custom-footer-testimonials-slider" display="1" offset="0" pagination="ajax" hide="response" fallback="No reviews yet."]
This creates a site review list of 1 single review item, with ajax pagination for all the rest. You can add more filters (such as categories) as per the documentation, to limit the number of “pages” as there will be one page per review.
Next, add the shortcode to your sidebar or footer widget using the WordPress Text Widget.
Ta da, you now have a single testimonial with pagination for the rest of them.Now let’s automate:
To do this, add the following JavaScript to your theme’s JavaScript file. For this you will need to google “how to enqueue javascript in your wordpress theme”. But if you have a JavaScript you are already loading, you just copy and paste the following into it, and if you changed the name of the “class” in the above shortcode, you have to replace it in the code below. This bit of code also supports pausing the review slide effect on hover over.var customFooterReviewsSliderPaused = false; var customFooterTimeoutFunctionID = undefined; $(".custom-footer-reviews-slider").bind("mouseenter", function() { customFooterReviewsSliderPaused = true; if (customFooterTimeoutFunctionID != undefined) { clearTimeout(customFooterTimeoutFunctionID); } }); $(".custom-footer-reviews-slider").bind("mouseleave", function() { customFooterReviewsSliderPaused = false; advanceCustomTestimonialsSlider(); }); function advanceCustomTestimonialsSlider() { $navLinks = $(".custom-footer-reviews-slider .nav-links"); $nextBtn = $("a.next.page-numbers", $navLinks); $prevBtn = $("a.prev.page-numbers", $navLinks); $pg1Btn = $('.page-numbers').not('.prev, .next').first(); if ($nextBtn.length > 0) { $nextBtn[0].click(); } else if ($pg1Btn.length > 0) { $pg1Btn[0].click(); } if (customFooterReviewsSliderPaused === false) { customFooterTimeoutFunctionID = setTimeout(function() { advanceCustomTestimonialsSlider(); }, 3000); } } /* Automate Testimonials As A Slider */ setTimeout(function() { advanceCustomTestimonialsSlider(); }, 3000); });
—————————-
My One Support Question:
—————————-
I noticed that even though the pagination uses Ajax that it is modifying the URI query string for each review viewed:
eg) the ?reviews-page=3 as so:
https://mywebsite.com/?reviews-page=3Since I am placing (say a dozen) select reviews in the footer, this will create a dozen ?indexable? permutations of every single page, which I’m not sure if Google will pick up on, but may not be a desired thing, I’m thinking.
I’m well versed in jQuery, JavaScript and PHP, so I may poke around in the JS of your plugin to see what I could potentially suppress.
PS: Amazing plugin! Truly well coded and thought out.
- The topic ‘Simple Review Slider / Carousel – How To Guide (and 1 Support Question)’ is closed to new replies.