0

I have created a custom page template, but I don't know how to add the WordPress comment form to my <body> tag. I tried to include the following in my template.php file in the body tag, but the form won't show up:

<?php $comments_args = array('label_submit' => __( 'Send', 'textdomain' ), 'title_reply' => __( 'Write a Reply or Comment', 'textdomain' ), 'comment_notes_after' => '',
        'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><br /><textarea id="comment" name="comment" aria-required="true"></textarea></p>',
);

comment_form( $comments_args ); ?>

I am using the child theme of twenty seventeen themes.

1 Answer 1

1

If you want to display default Wordpress comment form then you need to call comments_template() in your template. Make sure that comment_status should be open for the particular post that you want to display the comment form.

<?php
comments_template();
?>

Read more here https://developer.wordpress.org/reference/functions/comments_template/

2
  • Thank. Actually my code was correct. But that comment_status=open setting was missing
    – JoeBe
    Aug 22, 2018 at 13:20
  • Soo your code wasn't correct then :P
    – RuFFCuT
    Apr 3, 2021 at 2:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.