Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Comments Section Placement

  • Hi Guys

    I turned on comments, and I see that the comments section is being placed above two Hook Elements I have: Author Block and Essentials’

    How can I get comments placed after these two elements?

    Also, I noticed that the comment submit button is not displaying its label properly….what would control this?

    Thanks as always for your help!

    See test page below….

    Simon

  • Hi there,

    It’s best to alter the Hook of the Elements instead. Reference: https://docs.generatepress.com/article/hooks-visual-guide/#single-post

    Try the generate_before_comments_container hook.

  • Thanks Fernando

    If I change to generate_before_comments_container hook and then I have a page that I do not have comments on, will these elements still display?

    Simon

  • I think it should, but if it doesn’t it would be safer to use generate_after_do_template_part instead.

  • Hi Fernando, I tried generate_before_comments_container and that seems to work (see test page below).

    So now I need some help to learn how to style the comments section – sex max width, white background, font size for heading, text in field labels, text for opt-in notice.

    I am just not sure – does that require CSS or are there settings somewhere?

    Cheers Simon

  • Yes, you need CSS. Here’s a sample:

    .comments-area {
        max-width: 860px;
        margin-left: auto;
        margin-right: auto;
        padding: 60px;
        background-color: #fff;
    }
    
    .comments-area  h3#reply-title {
        font-size: 30px;
    }

    Let us know if you need to edit something specific.

  • Hi Fernando

    Thank you so much – ideal!

    Can I also ask:

    1. How can I remove the Website field all together?
    2. Change the text to “Save my name and email in my browser for the next time I comment.”
    3. Change the font size for the wording “Save my name, email, and website in this browser for the next time I comment.”

  • 1. Add this snippet:

    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) {
        unset($fields['url']);
        return $fields;
    }

    Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

    2. Try adding this PHP snippet:

    add_filter( 'comment_form_default_fields', 'tu_filter_comment_fields', 20 );
    function tu_filter_comment_fields( $fields ) {
        $commenter = wp_get_current_commenter();
    
        $consent   = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"';
    
        $fields['cookies'] = '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' . '<label for="wp-comment-cookies-consent">TEXT FOR CHECKBOX HERE</label></p>';
    
        return $fields;
    }

    3. Try adding this CSS:

    .comments-area p.comment-form-cookies-consent {
        font-size: 14px;
    }
  • Hey Fernando!

    Thanks again – really grateful. Perfect!

    Just one last mystery….how can I control the text colour, size and top-left and bottom right border radius of the submit button for the form? The colour is correct but the text unreadable and I’d like to adjust the radius.

    Cheers Simon

  • You’re welcome! Here’s a CSS you can try for that:

    .comments-area input#submit {
        color: #fff;
        font-size: 16px;
        border-top-left-radius: 16px;
        border-bottom-right-radius: 16px;
    }
  • Fernando

    You are legend!

    Thank you so much for your help today….

    I hope your day continues well!

    Cheers Simon

  • You’re welcome, Simon! Cheers!

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.