最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

comment form - Is there a way to edit the markup of comment_form()?

programmeradmin2浏览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.

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.

Share Improve this question asked May 11, 2020 at 12:32 Chillin'Chillin' 101
Add a comment  | 

1 Answer 1

Reset to default 0

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

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

  • comment_form_fields
  • comment_form_field_{$name}

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 );
发布评论

评论列表(0)

  1. 暂无评论