1. PROMO Subscribe our All Access Pass @ 75% OFF & access all our 16+ premium Divi extensions: Divi Block Pro, Carousel Toolkit, etc.LEARN MORE
Dismiss Notice
NEW Divi.Help Pro Carousel AI Toolkit - Magically turn your Divi design into carousel, simply by using our online toolkit. No plugins needed. Now it works with Divi 5 as well!Try our carousel AI toolkit
BEST Divi Block - A revolutionary drag & drop tool to easily mix & match 960+ premade blocks (Light & Dark) to kick start your Divi site design. Special module designs are included as well. Also newly added AI generator & color. Now it works with Divi 5 as well!
Learn More About Divi BlockFree Version ~ 340+ Free Blocks

Solved get last post date

Discussion in 'Free Divi Community Forum' started by n8!, Oct 15, 2021.

  1. n8!

    n8! New Member

    Hello dear Divi Team,

    I need your competent help again.
    On my page I show the last date when something was posted. But to change this date (simple text) manually after each post is quite time-consuming.

    In this context I tried to experiment with the "Dynamic Content" of divi. unfortunately without success.

    according to wordpress there is a function: "get_lastpostdate".

    https://developer.wordpress.org/reference/functions/get_lastpostdate/

    With this apparently the date can be displayed, when the last (blog)post was made. do i understand this correctly?

    the goal is therefore:
    The date should update automatically after a blogpost....
    is there something like a shortcode "get_lastpostdate"? or another idea how something like this can be implemented?

    thanks and many greetings

    n8
    date.png

    date.png
     
    1. PRO MEMBER PERKS Divi Block Pro - Premade slide in bar design for your Divi site without using any plugins:View Demo
  2. Divi.Help

    Divi.Help Administrator
    Staff Member

    Here's how to convert it to shortcode:
    Code:
    Log In or Sign Up to view this code.
    Paste it in your child theme functions.php

    And the shortcode is: [dh_last_date]
     
  3. n8!

    n8! New Member

    thanks! :)

    it does show the date... but actually very accurate. would it be possible to use the following format:
    Day / Month (fully written) / Year
    like "13 October 2021"
    ?

    Currently it displays the following:
    "2021-10-13 19:44:46.000000"
    (year / month (only number) / day / very accurate time)

    greetings!
     
    1. PRO MEMBER PERKS Divi Ultimate Archive Plugin - Replace the default archive "Older Entries" with beautiful pagination:Learn More
  4. Divi.Help

    Divi.Help Administrator
    Staff Member

  5. n8!

    n8! New Member

    the code now shows the correct format... but does not work "correctly".

    when i make a new blogpost, the date is not updated.
    however, if i use divi to go to the exact page where the text box with the code is located and save that exact page, i get an updated date.

    would it be feasible to add the "get_lastpostdate" instead of "get_the_modified_time"? the function "get_lastpostdate" worked in principle, but only showed a strange date format^^

    thanks!
     
    1. PRO MEMBER PERKS Divi Block Pro - Premade before / after image slider for your Divi site without using any plugins:View Demo
  6. Divi.Help

    Divi.Help Administrator
    Staff Member

  7. n8!

    n8! New Member

    Then I will work with this.
    Thanks for your clarification and support!
    many greetings!
     
    1. PRO MEMBER PERKS Divi.Help Pro Layout Packs - Agency Divi layout pack featuring modern overlay archive blog layout with hover effects:View Demo