[Resolved] How to show post published/ Updated date on Article?

Home Forums Support [Resolved] How to show post published/ Updated date on Article?

Home Forums Support How to show post published/ Updated date on Article?

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #2347026
    MD Tohidul

    Hello I want to show post published and Updated date on my every article of my website like this – (check screenshot) – https://prnt.sc/7dCgk6WHG-Bq

    How can I do this?

    #2347045
    Fernando
    Customer Support

    Hello there,

    Can you provide the link to the site in question? We’ll check your structure and think of an appropriate approach.

    You may use the Private Information field for this: https://docs.generatepress.com/article/using-the-premium-support-forum/#private-information

    #2347607
    MD Tohidul

    Hello Please check the private link

    #2347766
    Ying
    Staff
    Customer Support

    Hi there,

    Are you using any custom function or plugin to show the updated date on the blog page?

    If so, can you share the function?

    #2348046
    MD Tohidul

    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”>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”>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 );

    #2348072
    Fernando
    Customer Support

    Your code is good. Your sample screenshot showing your desired output shows only the updated date. To clarify, are you wanting to modify it to show both published and updated dates if the post has been updated?

    #2348087
    MD Tohidul

    Dear, when I go homepage or any category page of my website, I see the published and updated date.
    Check screenshot >>> https://prnt.sc/AmMcoVUNVmh0

    But, when I enter into the post link, I don’t see any date there. Only writer name is showing there.
    Check screenshot >>> https://prnt.sc/bFXZLEOZc-8q

    I just want to show article published and updated date beside writer name.

    For example please check the screenshot: https://prnt.sc/4siHMVGRkt9i

    #2348101
    Fernando
    Customer Support

    In Appearance > Customize > Layout > Blog > Single, can you check if “Display Post date” is enabled?

    #2348149
    MD Tohidul

    That’s perfect, after enabling the option now published and updated date is showing in my every single post.

    But, how can I do the same thing for my website page?

    Also, let me know how I can change the alignment of my website – post title, page title, author name, published date etc?

    #2348154
    Fernando
    Customer Support

    What website page are you referring to?

    Well, to make things easier, you can use a Post Meta – Block Element: https://docs.generatepress.com/article/block-element-post-meta-template/

    Alternatively, you can also use a Page Hero – Block Element: https://docs.generatepress.com/article/block-element-page-hero/

    #2348277
    MD Tohidul

    Please check the screenshot: https://prnt.sc/uKntknKRqdci
    This article is posted by post option in WordPress. And, It is showing the post published/updated date. That’s Great!

    And, check this screenshot: https://prnt.sc/rBSDtaOWquv-
    This article is posted by page option in WordPress. And, It doesn’t showing the post published/updated date.

    How can I show page author/published date in the article, which posted through page option?

    #2348747
    Ying
    Staff
    Customer Support

    Hi there,

    To add date to static pages, go to appearance > elements, create a new hook element, add this:

    <div class="entry-meta">
        <?php generate_posted_on(); ?>
    </div>

    Make sure the Execute PHP box is ticked.

    Choose pages > all pages as location, and publish the element.

    #2349017
    MD Tohidul

    After putting the code, here you see the result: https://prnt.sc/WEqibFE8luEN

    It’s showing in the upper section of my website page.

    How I can show the date after my website page title?
    like this – https://prnt.sc/QKhfYjsduCMx

    #2349064
    Fernando
    Customer Support

    Try to change the hook to generate_after_entry_header.

    For reference, here’s a visual guide of some hooks you may use: https://docs.generatepress.com/article/hooks-visual-guide/#static-page

    #2350273
    MD Tohidul

    Thanks dear, problem solved !

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