facetwp comments in layout builder

djrmom

{{gist file=”custom-hooks.php” lang=”php”}}
<?php
/** output comments in layout builder
** add a placeholder (Post ID is a good choice) to layout builder and name it comment-output
** replace the value with the filter below
** to change the template file for the output if you need it different comments on
** single posts, copy comments.php to a new file (ie – comments-builder.php)
** and include the file name in the function – comments_template( ‘/comments-builder.php’ );
**/
add_filter( ‘facetwp_builder_item_value’, function( $value, $item ) {
if ( ‘comment-output’ == $item[‘settings’][‘name’] ) {
global $withcomments;
$withcomments = “1”;
ob_start();
if ( comments_open() || get_comments_number() ) {
comments_template();
}
$value = ob_get_clean();
}
return $value;
}, 10, 2 );

{{/gist}}