Archived topic
Comments: Replace Headline for SEO Reasons
5 replies · Started by David on May 28, 2019
Hi there,
I just purchased GeneratePress and I'm really looking forward to relaunching the websites.
I want to follow up a discussion I opened at the Wordpress.org forums (https://wordpress.org/support/topic/seo-headline-h1-and-h2/) regarding the headline attribution in the comments section. There are two headlines I want to convert to normal text for SEO reasons.
Tom also marked out that there is no way for a custom function - which definitely would be the preferred way. If someone nevertheless has an idea - please let me know! :)
If the child theme way remains, this is where I got stuck:
- If there is a comment: “X Comments for ‘Article X'” (H3) => Found in the comments.php, class="comments-title". Change to div / span is easy possible.
- Every page: "Write a comment" (H3) => Not found in the comments.php - Where to adjust or edit it?
Thanks and best,
David
Hey David,
That specific text would need you to use a child theme, unfortunately: https://docs.generatepress.com/article/using-child-theme/
Then you would copy the comments.php file from the parent theme, and paste it into your child theme.
Then you can manually change those <h3> elements to whatever you like.
I'm not sure it's overly worth the hassle, as those <h3> elements certainly shouldn't hurt your site when it comes to SEO.
Let me know if you need more info :)
Hi Tom,
thanks for your help.
I followed your approach and I found the “X Comments for ‘Article X’” headline - in line 44 to 62. But that is the only h3 tag in the whole file. Where to find “Write a comment” (H3)?
Thanks and best,
David
You could try this:
add_filter( 'comment_form_defaults', function( $defaults ) {
$defaults['title_reply_before'] = '<h3 id="reply-title" class="comment-reply-title">';
$defaults['title_reply_after'] = '</h3>';
return $defaults;
} );
Hi Tom,
I had to replace the h3's in the snippet to p's as I wanted to get rid of the headlines. But then the snippet works perfectly.
I also decided to make this the only adjustment as I can configure it via my customs functions plugin. Then I just have one comment h3 which should be perfectly fine. ;-)
Thanks and best,
David
Awesome, glad I could help :)