A user wrote to me,
I've had numerous instances over the last couple of years where I've had to accommodate a client request to have a "testimonial rotator" - not an actual slider or carousel or anything, but just a tool that will display a "testimonial" in a spot (sidebar, or page), fade it out, fade in the next, and just cycle through.
...
What I'd *like* to be able to do is to add some code to take the basic Genesis Featured Posts widget - specify my post category, number of posts, order, etc. - and then have the resultant display output one post at a time, fading between, replacing each post with the next, in the same place where it would otherwise display the *list* of posts.
This can be done using a bit of jQuery. I am going to cover both the cases of rotating posts within a single widget and multiple widgets.
Step 1
Add the following in child theme's functions.php:
// Enqueue Scripts.
add_action( 'wp_enqueue_scripts', 'custom_enqueue_scripts' );
function custom_enqueue_scripts() {
wp_enqueue_script( 'rotating-posts', get_stylesheet_directory_uri() . '/js/posts-rotator.js', array( 'jquery' ), CHILD_THEME_VERSION, true );
}
Step 2
Create a file named say, posts-rotator.js
in child theme's js directory having the following code:
To view the full content, please sign up for the membership.
Already a member? Log in below or here.
Nice, Sridhar! Works perfectly!
Maybe I’m missing something.
It’s doing exactly what the css is telling it to do- “display:none;”
How to implement???
Thanks!
Can you provide the URL of your site?