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 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.

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.

Comments Shortcode Builder Options

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.

comment-repeater

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.

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.

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:

  1. Visit the Licenses section within the Ajax Load More plugin.
  2. Enter the product key and click Activate License.
  3. If the status indicator turns green your add-on has been successfully activated (example below).
License Key Example

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.