As well as a widget, the Better Recent Comments WordPress plugin comes with a shortcode. You can use this to insert a list of recent comments anywhere on your site, outside of a widgetized sidebar. For example, you may wish to list comments on a normal WordPress page.
Basic shortcode
To list recent comments, simply insert the shortcode [better_recent_comments] anywhere on your site.
Shortcode options
format – the format of each comment. This option uses 'merge tags' or ‘placeholders’ which are replaced with the correct data when the comments are displayed on your site. It defaults to {author} on {post}: “{comment}” {date}. You can change the format using the following placeholders:
{avatar} - the comment author’s Gravatar image (a placeholder image will be displayed if they don't have a Gravatar).
{author} - the name of the comment author.
{post} - the title of the post that the comment relates to. This links to the comment below the post.
{comment} - the actual comment text.
{date} - the comment date.
number – the number of comments displayed. Default: 5. Enter 0 if you want to display all comments on your site.
date_format – the date and time format to use when displaying the date. Like WordPress, this uses a PHP date format and defaults to ‘M j, H:i’. See a full list of date and time options.
avatar_size – the size of the avatar in pixels. Only used if you have included {avatar} in your comment format (see ‘format’ option). Default: 50.
post_status – the status of posts to retrieve comments for. Defaults to ‘publish’. Can be any valid status or a comma-separated list of statuses.
post_type - the post type to retrieve comments for. No default specified. Accepts a single post type (e.g. post) or use 'any' to show comments for all post types.
excerpts – set to ‘true’ to show an excerpt of the comment (limited to 20 words), or ‘false’ to show the full comment. Default: true.
Example shortcode
For example, you might use the following shortcode which combines all of the above options:
Better Recent Comments shortcode
As well as a widget, the Better Recent Comments WordPress plugin comes with a shortcode. You can use this to insert a list of recent comments anywhere on your site, outside of a widgetized sidebar. For example, you may wish to list comments on a normal WordPress page.
Basic shortcode
To list recent comments, simply insert the shortcode
[better_recent_comments]anywhere on your site.Shortcode options
format– the format of each comment. This option uses 'merge tags' or ‘placeholders’ which are replaced with the correct data when the comments are displayed on your site. It defaults to{author} on {post}: “{comment}” {date}. You can change the format using the following placeholders:{avatar}- the comment author’s Gravatar image (a placeholder image will be displayed if they don't have a Gravatar).{author}- the name of the comment author.{post}- the title of the post that the comment relates to. This links to the comment below the post.{comment}- the actual comment text.{date}- the comment date.number– the number of comments displayed. Default: 5. Enter 0 if you want to display all comments on your site.date_format– the date and time format to use when displaying the date. Like WordPress, this uses a PHP date format and defaults to ‘M j, H:i’. See a full list of date and time options.avatar_size– the size of the avatar in pixels. Only used if you have included {avatar} in your comment format (see ‘format’ option). Default: 50.post_status– the status of posts to retrieve comments for. Defaults to ‘publish’. Can be any valid status or a comma-separated list of statuses.post_type- the post type to retrieve comments for. No default specified. Accepts a single post type (e.g. post) or use 'any' to show comments for all post types.excerpts– set to ‘true’ to show an excerpt of the comment (limited to 20 words), or ‘false’ to show the full comment. Default: true.Example shortcode
For example, you might use the following shortcode which combines all of the above options:
[better_recent_comments number="10" date_format="F j, Y" format="{author} on {post}: “{comment}” {date}" avatar_size="75" post_status="draft,publish" excerpts="false"]Related Articles