• i am unable to remove URL field instead of pasting this code in function.php
    add_filter(‘comment_form_default_fields’, ‘url_filtered’);
    function url_filtered($fields)
    {
    if(isset($fields[‘url’]))
    unset($fields[‘url’]);
    return $fields;
    }

    can anyone help me please ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • try this in your ‘functions.php’ file

    function no_url_in_comments($fields) {
        unset($fields['url']);
        return $fields;
    }
    add_filter('comment_form_default_fields','no_url_in_comments');

    your ‘if‘ statement looks like it is formatted wrong.

    try this if you want an ‘if

    add_filter('comment_form_default_fields', 'url_filtered');
        function url_filtered($fields) {
            if ( isset($fields['url']) ) {
                unset($fields['url']);
                return $fields;
            }
    }

    Thread Starter tonystark007

    (@tonystark007)

    thanks but non of these code is working ??
    i paste them in function.phn top or bottom but still the url field exists in comment form ??

    any functions you add should be placed at the bottom of your ‘function.php‘ file. that code should work. unless your theme is rendering that field from some other way…

    Hi,

    Paste following code in your functions.php .

    add_filter( 'comment_form_defaults', 'url_filtered' );
    function url_filtered( $fields ) {
    
    if ( isset( $fields['url'] ) )
    unset( $fields['url'] );
    
    if ( isset( $fields['fields']['url'] ) )
    unset( $fields['fields']['url'] );
    
    return $fields;
    }

    Hope that helps !!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to remove URL field from comment form’ is closed to new replies.