I wanted to remove the URL field from the comment form in Generatepress Theme. I have created a child theme and the used below code.

add_action( 'after_setup_theme', 'tu_add_comment_url_filter' );
function tu_add_comment_url_filter() {
    add_filter( 'comment_form_default_fields', 'tu_disable_comment_url', 20 );

function tu_disable_comment_url($fields) {
    return $fields;

The code is working fine.

My Problem I wanted to remove the URL field code directly from the Theme so, I imported the same comments.php from the inc/structure folder to Child Theme rather than using the above code snippets.

When I remove this code from the parent theme, the URL field gets removed. It's working

    $fields['url'] = sprintf(
    '<label for="url" class="screen-reader-text">%1$s</label><input placeholder="%1$s" id="url" name="url" type="url" value="%2$s" size="30" />',
    esc_html__( 'Website', 'generatepress' ),
    esc_attr( $commenter['comment_author_url'] )

The Problem is: when I import the same comments.php creating the same folder name in Child Theme then the code is not working.

Is it possible to do this in Child Theme?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.