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

From IThemes Codex
Jump to: navigation, search

If you want to show just a comment form with your post on a single post page or archive page, add the following code at the end of your functions.php file (but before the closing ?>, if any).

Code

function my_insert_comment_form() {

    ob_start();
    comment_form();
    $my_comment_form = ob_get_contents();
    ob_end_clean();
 
    return $my_comment_form;
       
}
add_shortcode('insert-comment-form', 'my_insert_comment_form');

Usage

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

Additional documentation

comment_form function reference from WordPress Codex


← Back to LoopBuddy Codex Home

Personal tools
Namespaces
Variants
Actions
iThemes Codex
Codex Navigation
Toolbox