shortcode – wpv-post-comments
Sometimes it is useful to add WordPress post Comments in a Content Template or a View. It is possible to build a shortcode to display it:
// Display post Comments shortcode
add_shortcode('wpv-post-comments', 'my_post_comments');
function my_post_comments() {
ob_start();
comments_template();
$data = ob_get_clean();
return $data;
}
comments_template() reference: https://developer.wordpress.org/reference/functions/comments_template/
Then I can use this shortcode anywhere:
[wpv-post-comments]
You can find this solution on this Toolset forum thread:
https://toolset.com/forums/topic/show-comments-and-comments-form-within-a-view/
