[Resolved] Post Publish Date Missing on some posts

Home Forums Support [Resolved] Post Publish Date Missing on some posts

Home Forums Support Post Publish Date Missing on some posts

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2147089
    Sabbir

    Hello,

    Some of my posts have a published date and some don’t. Here are examples:

    Shows Published date: https://tier2tek.com/best-paying-jobs-in-technology/

    No Published date: https://tier2tek.com/success-factors-from-working-with-a-staffing-agency/

    I’m sure it’s a simple setting. Can someone help?

    BTW: I installed “Snippets” plugin and am using this code to display “Published date” and “last updated”. I don’t know much coding, I just copy/pasted it and it’s working.

    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_date() !== get_the_modified_date() ) {
    $time_string = ‘<time class=”entry-date published” datetime=”%1$s” itemprop=”datePublished”>Published on: %2$s</time> | <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 );

    #2147093
    Leo
    Staff
    Customer Support

    Hi there,

    The PHP snippet method is actually outdated.

    Can you try creating a block element post meta as instructed here?
    https://docs.generatepress.com/article/block-element-post-meta-template/

    It should be much easier without any coding required πŸ™‚

    #2147122
    Sabbir

    Thanks Leo,

    I’ll give this a try. But do you know why the Primary Post Meta is not showing up on some of my posts?

    #2147128
    Leo
    Staff
    Customer Support
    #2147132
    Sabbir

    Oooh, okay, thank you so much Leo! you’re awesome! I deactivated it and it’s working now.

    And thanks for taking the time to make the video about Block Element – Post Meta Template! I’ll try it out when I have some free time. Love how Generate Press keeps adding new features.

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