Menu Close

Display WordPress comment form using shortcode in between post content area

codeamend
PHP code helps you to display a small comment form within the content area of a post or page.
Add below codes in function.php file and use shortcode [codeamend_comment_form] to display the comment form in post or page content area.
add_shortcode( 'codeamend_comment_form', 'codeamend_comment_form_shortcode' );
function codeamend_comment_form_shortcode() {
    ob_start();
    comment_form();
    $cform = ob_get_contents();
    ob_end_clean();
    return $cform;
 } 
This code only prints the comment form. If you want to print the entire comment template use the comments_template(); function.

Share

Posted in WordPress, WordPress Shortcodes

You can also read...

Leave a Reply

Your email address will not be published.