• Resolved Christian Rodríguez

    (@hanschristian)


    Hi!

    Google is struggled with this. Google doesn’t understand what I’m asking for, as is showing me thousands of results with the same topic: “How to Display the Last Updated Date of Your Posts“.

    But I’m looking for the last updated date of the global site, the ENTIRE site.

    You can see exactly what I want right under the MailOnline logo: https://www.dailymail.co.uk/home/index.html

    The only result I found is this one. But isn’t working to me.

    If someone can help me on how to use this data in a shortcode (I’m planning to show this information in a widget), would be even better.

    Thank you in advance!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello @hanschristian

    There are some plugins that can help you achieve this goal. You can check this one “Posts Modified Date“. I know some themes like Blocksy has this functionality by default. You can turn it off and on in the customizer.

    I hope this helps.

    Regards,
    Rayhan Arif

    Thread Starter Christian Rodríguez

    (@hanschristian)

    Am I asking the most complicated simple question in the WordPress knowledge? : )

    Moderator bcworkz

    (@bcworkz)

    The stack exchange answer you linked to IS the right approach. But the devil is in the details. The specific details applicable to your situation is why the offered solutions do not work for you. The offered solutions are incomplete, you need to fill in the gaps.

    You need to alter whatever template is used for where you want the date to appear. Your specific code wouldn’t var_dump() query results, but the var_dump will show you how to get to the date you are looking for. You would echo out that specific element of the dumped data.

    Thread Starter Christian Rodríguez

    (@hanschristian)

    I found my own solution!

    Thanks @bcworkz. As I’m not a backend developer, this explanation sounds complicated to me.

    But some minutes ago, my brain lightened an idea to solve this issue. This is the way that worked for me, step by step:

    • Install the plugin Shortcodes Ultimate (which I use for a lot of things).
    • Note: I’m using “Disable Gutenberg” plugin and using the classic editor (Gutenberg blocks are a horror nightmare).
    • In our theme (preferably a child theme) we need to create a new folder and file that I will name “lastupdate-loop.php” here: /wp-content/themes/OURTHEME/templates/lastupdate-loop.php
    • This file would be used by Shortcodes Ultimate. Edit that new file and paste the following code:
    <?php defined( 'ABSPATH' ) || exit; if ( $posts->have_posts() ) :  while ( $posts->have_posts() ) : $posts->the_post(); ?>
    <?php echo get_post_modified_time('G:i T, l j F Y'); ?>
    <?php endwhile;  else : ?>
    <p class="su-posts-not-found"><?php esc_html_e( 'Posts not found', 'shortcodes-ultimate' ); ?></p>
    <?php endif; ?>
    • In any widget or post/page (I’m showing this info using a widget in a dynamic sidebar), paste the following shortcode:
    Last update time: [su_posts template="templates/lastupdate-loop.php" posts_per_page="1" post_type="post,page" order="desc" orderby="modified" post_status="any"]

    What this shortcode exactly does?

    This shortcode is showing the content for all the post and pages (post_type=”post,page”), with any post status (draft or published), and I’m calling only one item (posts_per_page=”1″), sort by modified date (order=”desc” orderby=”modified”).

    It would return the last post or page I modified and, as you can see in the template I made, I’m showing only the_modified_time, which is the only data I need.

    In the template code I used the following date format:

    <?php echo get_post_modified_time('G:i T, l j F Y'); ?>

    To show the date in the format you want, read Customize date and time format.

    Complicated… And tricky!

    I know.

    But, as I’m not a backend, I really needed to find a shortcode solution that helps me to tell the users when whas the last time I made some changes in the website.

    Cheers!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to display the last update time on THE SITE?’ is closed to new replies.