• Hi team,
    I need a help with the post date published and update. I have add the code found from your forum and added in the them. But still it is not displaying in the front end. Please help me.
    For your reference, I have attached the screenshot below
    https://prnt.sc/wSSDvTFg8rNc

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi @nebadita,

    What code are you using? Can you provide a link to your post?

    Thread Starter nebadita

    (@nebadita)

    Hi,
    I am using the following code:

    add_filter( 'generate_post_date_output', function( $output, $time_string ) {
    
        $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
    
        if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
    
            $time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Last Updated On %4$s</time>';
    
        }
    
        $time_string = sprintf( $time_string,
    
            esc_attr( get_the_date( 'c' ) ),
    
            esc_html( get_the_date() ),
    
            esc_attr( get_the_modified_date( 'c' ) ),
    
            esc_html( get_the_modified_date() )
    
        );
    
        return sprintf( '<span class="posted-on">%s</span> ',
    
            $time_string
    
        );
    
    }, 10, 2 );

    Here is my post link

    Try this:

    add_filter( 'generate_post_date_output', function( $output, $time_string ) {
    	
    $time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Published on %2$s</time>';
    
    if ( get_the_date() !== get_the_modified_date() ) {
    	$time_string = '<time class="entry-date updated-date" datetime="%3$s" itemprop="dateModified">Updated: %4$s</time>
    	<time class="entry-date published" datetime="%1$s" itemprop="datePublished">Published: %2$s</time>';
    }
    
    $time_string = sprintf( $time_string,
    esc_attr( get_the_date( 'c' ) ),
    esc_html( get_the_date() ),
    esc_attr( get_the_modified_date( 'c' ) ),
    esc_html( get_the_modified_date() )
    );
    
    return sprintf( '<span class="posted-on">%s</span> ',
    $time_string
    );
    }, 10, 2 );
    Thread Starter nebadita

    (@nebadita)

    Hi,
    Thanks for the code. I have changed it. Still not showing.

    For your reference, I have attached the screenshot below

    https://prnt.sc/qIQHcK-NyR0N

    Thread Starter nebadita

    (@nebadita)

    Hi,
    Thanks.. Now it is showing. But now the published and updated word is showing double double. For your reference, I have attached the screenshot below.

    https://prnt.sc/k5RRwMP78nmi

    And also why it is not displaying when I am activating generatepremium? Please let me know how can I able to display this on gp premium?

    Hi there,

    please share a link to your site, so we can see the issue.

    And no we cannot tell you how to display this on GP Premium, as WordPress forbids us from providing support for premium plugins in this forum.

    Thread Starter nebadita

    (@nebadita)

    hi

    this is my post link

    The issue you mention here i do not see on the link you provided.

    Thread Starter nebadita

    (@nebadita)

    hi,

    please refresh the link once. You will able to see..

    ying

    (@yingscarlett)

    The link you provided is using GP premium feature (block element – post meta template), it’s not the default GP template, so the code will not work. And the published on text is there before the date, I don’t see the issue you described.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Need help with post date’ is closed to new replies.