How to use it
- Select a Container, Block or Div and turn on its query loop.
- In the Query editor, choose the query type Comments / reviews (Kiln).
- Under the Query control, set what to loop over:
- Comments of: The current post, Any post (site-wide) or Specific posts.
- Post IDs: shown for Specific posts. Enter IDs such as
12, 34. Dynamic data is allowed. - Type: Comments (the default), Product reviews or Both.
- Number: from 1 to 100. The default is 10.
- Order: Newest first (the default) or Oldest first.
- Top-level only (no replies): tick it to leave out replies.
- Minimum rating (reviews): from 1 to 5. Shown when Type is Product reviews or Both.
- Inside the loop, add the tags below from the dynamic data picker (group Kiln) or type them.
Tags
{kiln_comment_author}: the author's name.{kiln_comment_content}: the comment text. Add a word count to shorten it:{kiln_comment_content:25}.{kiln_comment_excerpt}: a short plain-text excerpt. A number sets the words:{kiln_comment_excerpt:15}.{kiln_comment_date}: the date in your site's date format. Add a PHP date format to change it:{kiln_comment_date:Y-m-d}.{kiln_comment_avatar}: the avatar. In a text field it prints an image tag. As an image source it gives the image. A number sets the size in pixels:{kiln_comment_avatar:64}.{kiln_comment_rating}: the review rating as a number from 1 to 5.{kiln_comment_stars}: the rating as stars, for example ★★★★☆. In text it carries a label for screen readers ("4 out of 5 stars").{kiln_comment_link}: the URL of the comment.{kiln_comment_post_title}: the title of the post the comment belongs to.{kiln_comment_post_link}: the URL of that post.{kiln_comment_id}: the comment ID.
Where it appears in Bricks
- Query editor: the query type Comments / reviews (Kiln).
- Container, Block, Div, Content tab, directly under the Query control: the fields above. They show while that query type is chosen.
- Dynamic data picker: the tags, in the Kiln group, labelled "Comment: author name", "Comment: content" and so on.
Styled stars
{kiln_comment_stars} prints text characters, which take one color. For icon stars with their own colors, add
Bricks' Rating element inside the loop and set its Rating field to {kiln_comment_rating}. The Rating
element brings icons, full and empty colors, size and gap.
How it works with Bricks
- The current post is the post of the nearest loop around this one: a post loop item, or the post of a comment. Outside a loop it is the preview post in the builder, or the page being viewed on a single post or page. On an archive, the blog index or the shop there is no current post, so the loop is empty.
- A rating comes from the comment's
ratingvalue. With Both, a Minimum rating (reviews) above 1 also hides comments that have no rating. - Dates, ratings and the other tags work only inside a Kiln comments loop. Elsewhere they print nothing.
Limits
- Kiln lists only approved comments on published posts. Comments on drafts, private posts and password-protected posts never show.
- Any post (site-wide) and Specific posts use public post types only.
- Only the comment types
commentandrevieware listed. Comment types from other plugins stay out. - The loop has no pagination. Number is the most you get, up to 100.
- Braces in a comment's text are encoded, so a visitor cannot enter a Bricks tag in a comment and have it run.
- The avatar tag prints nothing when avatars are off (Settings > Discussion).
- If your site or another plugin turns on the
bricks/dynamic_data/replace_nonexistent_tagsfilter, Bricks blanks unknown tags before Kiln resolves them. Then{kiln_comment_avatar}as an image source and{kiln_comment_link}as a link target come out empty. Tags inside text still work.
Settings
None. Turn the module on in Bricks > Kiln (it is on by default).
For developers: the kiln/comments_loop/args filter changes the arguments Kiln passes to get_comments(). It
receives the arguments and the Bricks query object. Kiln still drops comments on password-protected posts after
the query.
Requirements
Bricks 2.4 or newer. The module does not need WooCommerce. Product reviews show up when WooCommerce, or
another plugin, saves comments of type review.