[Resolved] Remove comment meta link and time from the comment meta

Home Forums Support [Resolved] Remove comment meta link and time from the comment meta

Home Forums Support Remove comment meta link and time from the comment meta

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2363375
    Saurabh

    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,
    Saurabh

    #2363429
    Fernando
    Customer Support

    Hi Saurabh,

    You can add add_filter( 'generate_show_comment_entry_meta', '__return_false' ); then create a Hook Element hooked to generate_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.

    #2364044
    Saurabh

    Hi 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,
    Saurabh

    #2364386
    Tom
    Lead Developer
    Lead Developer
    #2364513
    Saurabh

    Thanks 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 the widget-area or outside the content-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?

    #2366002
    David
    Staff
    Customer Support
    #2366651
    Saurabh

    Thanks a ton for your help, David. It works perfectly.

    #2367003
    David
    Staff
    Customer Support
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.