Can't remove website field in comment form (Wordpress 3.0)
I followed the instructions in this site but there's no such code inside the comment.php
. I'm using Starkers theme but there's nothing inside which seems to control the website field.
Is it in a nw position now in Wordpress 3.0?
Where is开发者_运维百科 it?
The comment form is controlled by the comment_form()
function. You have 2 options if you want to change it's output:
- Change the
$fields
argument when you call it to remove thecomment_author_url
. - Filter the output of the function in your theme's
functions.php
.
Fields argument
$your_fields = array(
'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
);
comment_form(array('fields' => $your_fields));
Filter
function your_comment_form_fields($the_form_fields){
// code to remove the author field from $the_form_fields
return $the_form_fields;
}
add_filter('comment_form_default_fields', 'your_comment_form_fields');
Go to wp-content\themes\suffusion\comments.php file
suffusion is my theme name , you should go to your respective theme folder
find this block of code
comment_form(apply_filters('suffusion_comment_form_fields', array(
'fields' => array(
'author' => $author_field,
'email' => $email_field,
// 'url' => $url_field, // comment this field
),
and just comment the url field . It is working in my case .
you can check site for reference
The post below explains how to remove the website field from the comment form. Since it's not specific to theme or core files, it should work in all recent and future versions of Wordpress.
http://techhacking.com/2011/02/04/stop-comment-form-spam-in-the-website-field/
I'm using Starkers as well, and was not able to remove the website field by passing no "url" key or a null "url" key in the fields argument. This is because Starkers is using its own custom function in functions.php to apply a filter to comment_form_default_fields. Check on modifying the comment form through:
function starkers_fields($fields)
It is doing:
add_filter('comment_form_default_fields','starkers_fields');
Now I can more easily style the label and required asterisk as well. The required asterisk had no wrapper element, which made alignment styling a problem.
Please add this code in your theme's functions.php
function crunchify_disable_comment_url($fields) {
unset($fields['url']);
return $fields;
}
add_filter('comment_form_default_fields','crunchify_disable_comment_url');
精彩评论