[Resolved] How to import comments.php in Child Theme?

Home Forums Support How to import comments.php in Child Theme?

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1235987
    Suraj Katwal

    Hi, I am writing a tutorial on how to Remove URL Field From Comment form in GeneratePress. So, with different methods, I have included removing Website Field using a Child Theme.

    What I have done until now is
    1. Download the Child Theme
    2. Upload > Activate
    3. Make an inc > directory and import comments.php in Child Theme.

    Actually I want to remove Comment URL Field

    $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'] )
    	);

    Q. How to import comments.php to child Theme?

    SEO, WordPress Optimization, Blogging Tutorials.
    GeneratePress Tutorial: https://www.wplogout.com

    #1236385
    Leo
    Staff
    Customer Support

    Hi there,

    We do have that documentation already:
    https://docs.generatepress.com/article/remove-e-mail-and-url-field-from-comment-form/

    Q. How to import comments.php to child Theme?

    Just copy the comments.php file from the parent theme:
    https://github.com/tomusborne/generatepress/blob/master/comments.php

    And paste into the child theme’s folder.

    #1236721
    Suraj Katwal

    Hi LEO, I have already implemented the Code Snippet method but I want to remove URL Field using Child Theme Method.

    $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'] )
    	);

    Thanks

    SEO, WordPress Optimization, Blogging Tutorials.
    GeneratePress Tutorial: https://www.wplogout.com

    #1237070
    David
    Staff
    Customer Support
    #1237291
    Suraj Katwal

    Hi David, I know about this method, also I know about CSS code to hide website input box and using a plugin we can do so. But I am writing a tutorial where I want to remove the below code from Inc > structure > comments.php folder.

    $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'] )
    	);

    So, this is for the tutorial purpose.
    I am writing tutorial so I have listed 4 methods and among theme removing code directly is the 4th method and I removed the code in the comments.php by importing in child theme but it’s not working.

    Thank You.

    SEO, WordPress Optimization, Blogging Tutorials.
    GeneratePress Tutorial: https://www.wplogout.com

    #1237542
    Leo
    Staff
    Customer Support

    We are both not sure what you are trying to do unfortunately.

    You will have to figure it out for your tutorial – it seems to be an overly complicated way to do it.

    #1238871
    Suraj Katwal

    Hi Again,
    While removing the URL field code in GeneratePress Parent Theme, I was able to remove the Website URL field but after importing the same files with the same folder name is child Theme, it’s not working.

    To override the parent theme files, we have to import the same to the child theme and edit it, right?

    Can you please help me with this, please.

    Thank You.

    SEO, WordPress Optimization, Blogging Tutorials.
    GeneratePress Tutorial: https://www.wplogout.com

    #1239301
    Leo
    Staff
    Customer Support

    The theme’s comments.php actually doesn’t control this.

    This filter is a WordPress filter and unrelated to the theme:
    https://docs.generatepress.com/article/remove-e-mail-and-url-field-from-comment-form/

    The file you are looking for should be the comment.php file in the WordPress folder under wp-includes.

    You will need to do some research on how to include/overwrite that in your child theme (it’s not a good idea generally when there is already a filter available).

    Sorry but writing your tutorial isn’t something the theme support should help with. Perhaps try a site like this for general questions?
    https://wordpress.stackexchange.com/

    #1239371
    Suraj Katwal

    Thank You

    SEO, WordPress Optimization, Blogging Tutorials.
    GeneratePress Tutorial: https://www.wplogout.com

    #1239403
    Leo
    Staff
    Customer Support
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.