Add Post Comments to a Single Post or to Posts in the Post List (Archive Page)

From IThemes Codex
Jump to: navigation, search

If you want to add comments, and a comment form to a post, add the following code at the end of your functions.php file (but before the closing ?>, if any).

Code

function my_insert_comments() {

    ob_start();
    global $withcomments;
    $withcomments = true; 
    comments_template();
    $my_comments = ob_get_contents();
    ob_end_clean();
 
    return $my_comments;
    
}
add_shortcode('insert-comments', 'my_insert_comments');

Usage

Insert the shortcode [insert-comments] in your LoopBuddy layout where you want the comments to appear.

Additional documentation

comments_template function reference from WordPress Codex


← Back to LoopBuddy Codex Home

Personal tools
Namespaces
Variants
Actions
iThemes Codex
Codex Navigation
Toolbox