Comments Shortcode for Content Templates

Author: Aleš Sýkora, 11. 11. 2019

The challenge: display comments section in Bootstrap grid in content template of custom post type.

The solution: create custom shortcode for calling comments.php template.

The code:

function comments_template_shortcode() {
comments_template( '/comments.php' );
$cform = ob_get_contents();
return $cform;
add_shortcode( 'comments-template', 'comments_template_shortcode' );

How to: Put this code in Toolset > Settings > Custom Code and activate it. Then use comments-template shortcode in your content template.