Menu Close

Display WordPress comment form using shortcode in between post content area

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() {
    $cform = ob_get_contents();
    return $cform;
This code only prints the comment form. If you want to print the entire comment template use the comments_template(); function.
Posted in WordPress, WordPress Shortcodes

You can also read...