开发者

How to remove a comment form field in WordPress?

Most strings and form fields may be controlled through the $args array passed into the function, while you may also choose to use the comment_form_default_fields filter to modify the array of default fields if you'd just like to add a new one or r开发者_StackOverflow社区emove a single field. All fields are also individually passed through a filter of the form comment_form_field_$name where $name is the key used in the array of fields.

the above is from the wordpress manual. but i don't follow it well. anyone can give me an example to explain how to remove a field and add a field.

if i want to remove the comment_notes_before. how should i do? thank you.


function change_fields($fields) {
    //remove a field
    unset($fields['comment_notes_before']);
    //add a field
    $fields['my_field'] = '<p>My New Field HTML</p>';
    //return the modified array of fields
    return $fields;
}

add_filter('comment_form_default_fields','change_fields');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜