- This topic has 5 replies, 2 voices, and was last updated 3 years, 2 months ago by
Fernando.
-
AuthorPosts
-
December 25, 2022 at 5:42 pm #2473176
Scott
I don’t think this is actually a generatepress issue but I’ll post it anyway to see if anyone has a solution.
If one allows commenting on posts in a WordPress site the comment box itself seems to not be addressed by the theme. Basically one will have the title of the comment box hard coded to be an h3 heading. This can be problematic if you have anything h4 or smaller before the comment box.
I can and have edited the core WordPress file /includes/comment-template.php at lines 2486 and 2487 to change the h3 to P because if in the content of the post you don’t use any other headings pagespeed insights will throw an accessibility error that the headings are not in a descending sequential order.
I can change text size color etc of this title via css but I don’t think css can change an h3 to anything else.
If anyone knows how I can do this via css please share. Or maybe a code snippet could do this the functions are title-reply-before and title-reply-after on lines 2486 and 2487.
Merry Christmas
December 25, 2022 at 9:05 pm #2473279Fernando Customer Support
Hi Scott,
To clarify, are you referring to the “Leave a Comment” text? If so, you’re right. You’ll need to create an alternative Comment Template to do this: https://developer.wordpress.org/reference/functions/comments_template/#user-contributed-notes
The only filter that exists for the Heading is for changing its text –
comments_template– https://github.com/tomusborne/generatepress/blob/4895a2e7595bb809075b375201fd735112f41570/inc/structure/comments.php#:~:text=%24defaults%5B%27title_reply%27%5D%20%20%20%20%20%20%20%20%20%20%3D%20apply_filters(%20%27generate_leave_comment%27%2C%20__(%20%27Leave%20a%20Comment%27%2C%20%27generatepress%27%20)%20)%3BDecember 25, 2022 at 9:49 pm #2473297Scott
Hey thank you for the reply. It’s way over my head though. But it seems like an awful lot just to change a h3 to a P.
Because I have a percentage of clients who are dependent on assistive technologies the fact WordPress decided to hardcode the h3 into their core file presents a problem for some that are disabled.
For now until I can find a fix the typical WordPress user can negotiate I’ve just edited the WordPress file and made the perms on it immutable so that it can’t be overwritten.
December 25, 2022 at 11:20 pm #2473333Fernando Customer Support
Actually, can you try this snippet and see if it works?:
add_filter('comment_form_defaults',function($defaults){ $defaults['title_reply_before'] = '<p id="reply-title" class="comment-reply-title">'; $defaults['title_reply_after'] = '</p>'; return $defaults; }, 10, 1);Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
December 26, 2022 at 1:40 pm #2474120Scott
Works like a charm!
Thank you
December 26, 2022 at 5:01 pm #2474235Fernando Customer Support
You’re welcome, Scott! Glad that worked!
-
AuthorPosts
- You must be logged in to reply to this topic.