- This topic has 7 replies, 4 voices, and was last updated 1 year, 6 months ago by David.
-
AuthorPosts
-
October 4, 2022 at 4:09 pm #2363375Saurabh
Hi David / Tom,
I would like the comment meta should only output the date (October 04, 2022) with the default schema timestamp – no link and no time.
The following filter which was introduced in GP 3.1.0 filter stops the comment meta totally so that didn’t solve my problem.
add_filter( 'generate_show_comment_entry_meta', '__return_false' );
I further tried these core WP filters, but they also do not work as required.
1. This removes the link but the anchor tag ….. remains.
add_filter( 'get_comment_link', '__return_false' );
2. This filter does remove the comment time but also removes the schema and leaves “at” after the date.
add_filter( 'get_comment_time', '__return_false' );
Is there any way to achieve only the date in the comment meta? Can you help me with that?
Regards,
SaurabhOctober 4, 2022 at 6:16 pm #2363429Fernando Customer SupportHi Saurabh,
You can add
add_filter( 'generate_show_comment_entry_meta', '__return_false' );
then create a Hook Element hooked togenerate_after_comment_author_name
.With this content for instance:
<time datetime="<?php comment_time( 'c' ); ?>" itemprop="datePublished"> <?php printf( /* translators: 1: date, 2: time */ _x( '%1$s', '1: date', 'generatepress' ), // phpcs:ignore get_comment_date() // phpcs:ignore ); ?> </time>
Make sure
Execute PHP
is enabled.October 5, 2022 at 7:31 am #2364044SaurabhHi Fernando,
Thanks for the snippet, it worked perfectly.
Although I have modified it a bit and added the link to edit comments in order to keep the original functionality.
<?php add_filter( 'generate_show_comment_entry_meta', '__return_false' ); ?> <div class="entry-meta comment-metadata"> <time datetime="<?php comment_time( 'c' ); ?>" itemprop="datePublished"> <?php printf( /* translators: 1: date, 2: time */ _x( '%1$s', '1: date', 'generatepress' ), // phpcs:ignore get_comment_date() // phpcs:ignore ); ?> </time> <?php edit_comment_link( __( 'Edit', 'textdomain' ), '<span class="edit-link">| ', '</span>' ); ?> </div>
Have added The above snippet to the custom Hook Element hooked to
generate_after_comment_author_name
and it works as expected.Thanks a ton for your help.
Regards,
SaurabhOctober 5, 2022 at 10:17 am #2364386TomLead DeveloperLead DeveloperHi there,
Just a heads up that 3.2.0 (current in beta: https://generatepress.com/generatepress-3-2-0/) has a filter to disable the link: https://github.com/tomusborne/generatepress/commit/040f170f169f4135e865f0a58699b41f3144d295
Hope this helps!
October 5, 2022 at 12:40 pm #2364513SaurabhThanks for the update, Tom. In the meantime, I will use the snippet above until the next stable release.
I have another question; how to move the
comment-area
after thewidget-area
or outside thecontent-area
?I recall it being discussed a couple of years back, but it did not work with the custom template, since the comments need to be within the content loop.
I am wondering how Genesis Framework and other page builders (like Elementor) are able to do it.?
Is there a workaround for that?
October 7, 2022 at 2:43 am #2366002DavidStaffCustomer SupportHi there,
see Toms reply here regarding moving the Comments Area:
https://generatepress.com/forums/topic/move-comments-section-before-the-footer/#post-1663535
October 7, 2022 at 3:21 pm #2366651SaurabhThanks a ton for your help, David. It works perfectly.
October 8, 2022 at 6:08 am #2367003DavidStaffCustomer SupportGlad to hear that!!
-
AuthorPosts
- You must be logged in to reply to this topic.