[Support request] Remove post date only if post date > 35 days

Home Forums Support [Support request] Remove post date only if post date > 35 days

Home Forums Support Remove post date only if post date > 35 days

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1054039
    Alex

    Hello,

    I have seen this post: https://support.rankmath.com/ticket/remove-published-date-from-google-results/

    And want to ask how i can add a filter to that function, so the date of the post is not showing in the source code in the posts of more than 35 days.

    Let me know please, regards!

    #1054394
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Would the entire post date remove itself? Or only the published/updated?

    You could try this:

    add_filter( 'generate_post_date_output', function( $output ) {
        if ( strtotime( $post->post_date ) < strtotime( '-35 days' ) ) {
            return '';
        }
    
        return $output;
    } );

    Let me know 🙂

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