Recently, I corresponded with someone who need to port the Genesis comments into a shortcode for a custom post type template (I'm assuming). However, doing it seemed challenging and a lot of hack work, but he reminded me of the genesis template part, which made it very doable.
Since I thought this was fairly novel idea, I thought I'd post about here.
[php]
remove_action( 'genesis_after_post', 'genesis_get_comments_template' );
function ts_genesis_comments_shortcode() {
ob_start();
genesis_get_comments_template();
$tsComments = ob_get_clean();
return $tsComments;
}
add_shortcode ('ts-genesis-comments', 'ts_genesis_comments_shortcode');
[/php]
First we need to remove the comments template via remove_action( 'genesis_after_post', 'genesis_get_comments_template' );
. Then we can get the comments via output buffering (ob_start() and ob_get_clean()).
Leave a Reply