Wordpress Comment Carousel Plugin

/* Plugin Name: Comment Carousel Description: Display comments in a carousel using a shortcode. Version: 1.0 Author: Your Name */ function enqueue_owl_carousel() { wp_enqueue_style('owl-carousel', 'https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css'); wp_enqueue_script('owl-carousel', 'https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js', array('jquery'), '', true); } add_action('wp_enqueue_scripts', 'enqueue_owl_carousel'); // Function to retrieve and format comments function get_comment_data() { $args = array( 'status' => 'approve', 'number' => 3, ); $comments_query = new WP_Comment_Query($args); $comments = $comments_query->comments; $comment_data = array(); foreach ($comments as $comment) { $comment_data[] = array( 'content' => $comment->comment_content, ); } return $comment_data; } // Display comments using a shortcode function comment_carousel_shortcode($atts) { ob_start(); $comment_data = get_comment_data(); if ($comment_data) { ?>
Previous
Next

Facebook Page