[Resolved] Change H3 in comments

Home Forums Support [Resolved] Change H3 in comments

Home Forums Support Change H3 in comments

  • This topic has 23 replies, 5 voices, and was last updated 6 months ago by Ying.
Viewing 15 posts - 1 through 15 (of 24 total)
  • Author
    Posts
  • #820241
    AJ

    Hi team,

    I am in the process of making a few changes to the comments section.

    I want to change <h3> tags into <strong> tags.

    I’ve managed to change the comments-title (“x thoughts on…”) successfully but am struggling to work out how to change the reply-title (“leave a comment”).

    I did find this ticket but it doesn’t explain the code changes required:
    https://generatepress.com/forums/topic/remove-h3-from-leave-comment/

    I’m sure it’s very easy, but I’m not seeing it.

    Thanks!

    GeneratePress 2.2.2
    GP Premium 1.7.8
    #820959
    David
    Staff
    Customer Support

    Hi there,

    in your child theme copy of the comments.php look for this section of code:

    https://github.com/tomusborne/generatepress/blob/6933da4f9a85e183bcf8485836339043dfc4a650/comments.php#L44-L62

    You can see the opening and closing <h3> just change them.

    #821263
    AJ

    Thanks David.

    That’s actually what I did but strangely enough that only changes the “x thoughts on…” header, not the “leave a comment” header.

    I am using the marketer template, if that makes a difference.

    #821318
    David
    Staff
    Customer Support

    Oops my bad… having one of those days. So you can filter the Reply title like so:

    add_filter( 'comment_form_defaults', 'custom_reply_title' );
    function custom_reply_title( $defaults ){
      $defaults['title_reply_before'] = '<strong id="reply-title" class="comment-reply-title">';
      $defaults['title_reply_after'] = '</strong>';
      return $defaults;
    }
    #821335
    AJ

    Thanks David, that worked nicely.

    #821353
    David
    Staff
    Customer Support

    Glad to be of help ( second time round lol )

    #1688447
    Jörg

    Hi,

    I would like to change the H3 too, but that solution is not working.

    Can you help me?

    Thanks

    #1688533
    Ying
    Staff
    Customer Support

    Hi Jörg,

    Could you open a new topic for your question instead of leaving comments in a resolved topic?

    In your new topic, could you specify which H3 you are trying to change?

    Thanks 🙂

    #1688542
    Jörg

    Hi,
    I would like to change the same H3 as AJ in the first place (in the comment section “x thoughts on…” and “leave a comment”. Because it’s the same topic, I commented here.
    I tried the solution from David, but it didn’t work.
    Sure, I should open a new topic with the same problem?
    Thanks

    #1688608
    Ying
    Staff
    Customer Support

    So you want to change the <H3> tag to<strong> as well?

    Or you just want to change the text?

    #1689093
    Jörg

    Hi,
    I want to change theH3 to a strong.

    #1689108
    Elvin
    Staff
    Customer Support

    Hi Jorg,

    David’s code found here should work:
    https://generatepress.com/forums/topic/change-h3-in-comments/#post-821318

    I’ve tested it myself to verify. See the comment title here: Demo

    You can see that Leave a comment got smaller because it’s using <strong> now instead of <h3>

    Perhaps there’s an issue with how you’re adding the PHP snippet. Can you tell us how you’re adding it to your site? Let us know.

    A wise man once said:
    "Have you cleared your cache?"

    #1689180
    Jörg

    Hi Elvin,
    I tried Davids fist solution (https://github.com/tomusborne/generatepress/blob/6933da4f9a85e183bcf8485836339043dfc4a650/comments.php#L44-L62) but in my comments.php I did not find the line:

    … if ( have_comments() ) : ?>
    <h3 class=”comments-title”> …

    And i dont know where I should insert the second solution:

    add_filter( ‘comment_form_defaults’, ‘custom_reply_title’ );
    function custom_reply_title( $defaults ){ …

    Where should I put this in?

    #1689953
    Ying
    Staff
    Customer Support

    You could use 1 of the methods from here to add php snippet:
    Adding PHP: https://docs.generatepress.com/article/adding-php/

    #1690142
    Jörg

    I copied this in the child theme functions.php (https://generatepress.com/forums/topic/change-h3-in-comments/#post-821318)
    That is fixing my problem for sites who have already one or more comments. On sites without a comment the “write a comment” title is still an H3.

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