[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

    Hi 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!

    #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

    Hi there,

    see Toms reply here regarding moving the Comments Area:

    https://generatepress.com/forums/topic/move-comments-section-before-the-footer/#post-1663535

    #2366651
    Saurabh

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

    #2367003
    David
    Staff
    Customer Support

    Glad to hear that!!

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