Comments Enable infinite scrolling of blog comments with Ajax Load More Plugins / Ajax Load More / Add-ons / Comments The Comments add-on will load and display blog comments using the core Ajax Load More infinite scroll functionality. Improve website performance, decrease load times and reduce stress on your server by lazy loading blog comments when requested by your users – view example. How It WorksShortcode ParametersImplementationInstallation Purchase Options Single Site – $35.00 Up to 5 Sites – $55.00 Up to 25 Sites – $79.00 Add to Cart Checkout Added to cart This add-on has a lifetime license and will not expire. How It Works The Comments add-on works by querying an individual blog/single post for user comments. Each comment and it’s replies are returned using the familiar Ajax Load More infinite scroll / lazy load functionality. View Comments Example By using a unique comment query, existing Ajax Load More functionality and core WordPress functions such as wp_list_comments, the Comments add-on is able to return post comments in an intuitive and user friendly format while helping improve the overall performance and user experience of your website. Pro-Tip: You can also lazy load Comments using the Paging add-on – view example. Shortcode Parameters The following shortcode parameters are available with the Comments add-on. comments Enable Ajax Load More to display blog comments. Default = ‘false’ comments_post_id The ID of the current single post. Default = ‘get_the_ID()’ comments_per_page The number of top level items to show for each page of comments. Default = ‘5’ comments_type The type of comment(s) to display. Default = ‘comment’ comments_style Select the HTML container style for your comments. Default = ‘ol’ comments_template Select a repeater template that will display comment data. Default = null comments_callback A custom callback function that will display each comment. Default = null Shortcode Builder The following screenshot illustrates the process of building a Comments shortcode using the Ajax Load More shortcode builder. Example Shortcode [ajax_load_more comments="true" comments_post_id="'.get_the_ID().'" comments_callback="my_theme_comments" pause="true" button_label="Load Comments"] Implementation Implementing comments with Ajax Load More is a two step process and will require modification of your single post template. Step 1 – Select Comment Template or Callback Function The first step will be to determine how you want Ajax Load More to display your comments – with the Comments add-on you can either select an existing callback function (from your theme) or create your own repeater template to handle the markup/display of your comments. Comment Template Creating your own custom template for displaying WordPress comments is a straight forward and intuitive process and is much like building a standard repeater template for Ajax Load More. Simply construct a repeater template using HTML and standard WordPress comment functions such as comment_date() and comment_author() then select this template when building out a comment shortcode. When building a custom comment template you should never close the opening HTML element – the closing </ li> is purposely left out of the template and will be closed by WordPress – View Gist Callback Function A comment callback is a function that is available from within a theme and is used to render and display each comment. When you enter a callback function name into the comments_callback shortcode parameter, Ajax Load More will attempt to render comments using this function. The majority of premium and custom themes have callbacks for displaying comments. Please see comments.php or functions.php within your theme directory to locate the callback function for your theme – see the example below. 1234567 <?php // comment.php // An example of where to find your the name of your themes callback function.?><ol class="commentlist"> <?php wp_list_comments( array( 'type' => 'comment', 'callback' => 'my_comment_callback' ) ); ?></ol> Callback Library Below is a collection of comment callbacks referencing the theme/plugin and callback function. WooCommerce: woocommerce_comments Step 2 – Adding Shortcode to Template Locate your existing comments_template() function and replace it with an Ajax Load More comments shortcode and other comment related functions as seen in the code sample below. 123456789101112131415161718192021222324252627282930313233 <?php// WordPress single template (single.php)// Displaying comments using Ajax Load More// https://connekthq.com/plugins/ajax-load-more/add-ons/comments/?><div class="post-container"><?phpif ( have_posts() ) : while (have_posts() ) : the_post(); ?> <article id="post-123"> <div class="post-content"> <h1><?php the_title(); ?></h1> <?php the_content(); ?> </div> <?php if(comments_open()) : ?> <footer id="comments"> <?php // comments_template(); // Removed in favor of Ajax Load More $comment_count = get_comment_count($post->ID); if ($comment_count['approved'] > 0) : echo '<h2 class="comments-title">Comments ('. $comment_count["approved"] .')</h2>'; echo do_shortcode('[ajax_load_more comments="true" comments_post_id="'.get_the_ID().'" comments_per_page="4" comments_style="ol" comments_template="default" pause="true" button_label="Load Comments"]'); endif; comment_form(); // Standard WP Comment form ?> </footer> <?php endif; ?> </article> <?php endwhile; endif; ?></div> In most cases you will be directly editing single.php but dependent on your theme you may need to edit another file – e.g. index.php. Installation Upon purchase of this add-on you will receive a confirmation/purchase receipt email. Your receipt will contain a direct link for downloading your copy of Ajax Load More: Comments and a license key. After downloading the add-on, upload the unzipped files to your /wp-content/plugins/ directory or visit your plugins dashboard and upload the downloaded .zip under Add New. License Activation To activate your add-on and receive updates directly in your WordPress plugins dashboard users are required to enter the license key that was included with their purchase receipt. To activate a license key: Visit the Licenses section within the Ajax Load More plugin. Enter the product key and click Activate License. If the status indicator turns green your add-on has been successfully activated (example below). If you did not receive your confirmation/purchase receipt email and license key, please check your spam/junk folder and if you still cannot locate the email please contact me at darren [at] connekthq.com or use the contact form on this website.