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.
Maintain the current comments look and feel by using the comment styling from your theme.
Add-on Details
Learn more about the Comments add-on.
How It Works
The Comments add-on works by querying individual posts for user comments or reviews. Each comment and replies are returned using the familiar Ajax Load More infinite scroll / lazy load functionality.
By using a unique comment query, existing Ajax Load More functionality, and core WordPress functions such as wp_list_comments, the Comments add-on can return post comments or WooCommerce reviews 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.
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 custom template for displaying WordPress comments is a straightforward and intuitive process and is a lot like building a standard Repeater Template for Ajax Load More.
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.
<?php// comment.php// An example of where to find your the name of your themes callback function.?><olclass="commentlist"><?phpwp_list_comments(array('type'=>'comment','callback'=>'my_comment_callback')); ?></ol>
PHP
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.
<?php/** * WordPress single template (single.php). * Displaying comments using Ajax Load More * * @see https://connekthq.com/plugins/ajax-load-more/add-ons/comments/ */?><divclass="post-container"><?phpwhile (have_posts() ) :the_post(); ?><articleid="post-123"><divclass="post-content"><?phpthe_title('<h1>','</h1>');the_content(); ?></div><?phpif(comments_open()) :?><footerid="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>';echodo_shortcode('[ajax_load_more comments="true" comments_post_id="'. get_the_ID().'" comments_per_page="4" comments_style="ol" comments_template="default" button_label="Load Comments"]');endif;comment_form(); // Standard WP Comment form.?></footer><?phpendif; ?></article><?phpendwhile; ?></div>
PHP
In most cases, you will be directly editing single.php but depending 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 a confirmation email containing your license key, please check your spam/junk folder. If you still cannot locate the email, contact me at darren [at] connekthq.com or use the Product Support form.
Comments
Enable infinite scrolling of blog comments with Ajax Load More
PluginsAjax Load MoreAdd-ons
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.
Add-on Pricing Billed annually until cancelled.
All purchase options are billed annually in USD with a renewal discount of 30%. View Terms
Features
A few key features of the Comments add-on for Ajax Load More.
Boost Performance
Reduce queries on initial page load by loading comments only when requested by visitors.
View Example
WooCommece Reviews
Display native WooCommerce product reviews in an infinite scroll or load more listing.
View Example
Theme Integration
Maintain the current comments look and feel by using the comment styling from your theme.
Add-on Details
Learn more about the Comments add-on.
How It Works
The Comments add-on works by querying individual posts for user comments or reviews. Each comment and replies are returned using the familiar Ajax Load More infinite scroll / lazy load functionality.
By using a unique comment query, existing Ajax Load More functionality, and core WordPress functions such as wp_list_comments, the Comments add-on can return post comments or WooCommerce reviews 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.
Examples
Default Comments
Displaying out-of-the-box WordPress comments with Ajax Load More.
WooCommerce Reviews
Display WooCommerce product reviews using Ajax Load More and infinite scroll.
Shortcode Parameters
The following shortcode parameters are available with the Comments add-on.
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 custom template for displaying WordPress comments is a straightforward and intuitive process and is a lot like building a standard Repeater Template for Ajax Load More.
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 GistCallback 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.
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.
In most cases, you will be directly editing single.php but depending 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:
If you did not receive a confirmation email containing your license key, please check your spam/junk folder. If you still cannot locate the email, contact me at darren [at] connekthq.com or use the Product Support form.