0

I have a single.php page where I call the the_content() function, followed by the comment_form() function to display the comment box.

While this function does display the logged in user, link to log out, textarea for comment, and post button, and I can edit the CSS, I'm wondering if there a way to edit the markup that is generated.

I've found a link that details the markup of comment.php from TwentyTwenty theme, but does not include the markup for said comment box.

The two main things I'd like to do is; add the users avatar next to the comment box, and add css classes to the button and textarea for styling.

1 Answer 1

0

I covered just the other day some of the comment (textarea) filters here, https://wordpress.stackexchange.com/a/366147/144392

But the filters you may want to look into are most likely,

EDIT 11.5.2020: Codex example for comment_form($args),

$comments_args = array(
        // Change the title of send button 
        'label_submit' => __( 'Send', 'textdomain' ),
        // Change the title of the reply section
        'title_reply' => __( 'Write a Reply or Comment', 'textdomain' ),
        // Remove "Text or HTML to be displayed after the set of comment fields".
        'comment_notes_after' => '',
        // Redefine your own textarea (the comment body).
        '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 );
2
  • Thanks for your comment. I'm creating my own theme so I don't have thecomment-template.php file. I've created it, edited the markup and called it using ` <?php comment_form('/comments-template.php'); ?>` but the markup is still the default. Am I doing something wrong? p.s. the path is correct
    – Chillin'
    Commented May 11, 2020 at 14:04
  • @Chillin' I'm sorry, I read your question poorly. The comment_form function takes as the first parameter an array in which you can include the required modifications. You can see all of the available keys for the config array in the code reference, developer.wordpress.org/reference/functions/comment_form. Commented May 11, 2020 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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