Add Last Updated Date To Post Info In Genesis

This code removes the published date and displays the last time you clicked update for the post.

Add the PHP code to the end of your child themes functions.php file using a code editor like Notepad++.

That’s all you need to do.

The updated date is now included in genesis > lib > shortcodes > post.php.

Other Options


Comments

22 responses to “Add Last Updated Date To Post Info In Genesis”

  1. Kristie Avatar
    Kristie

    Thanks! Worked perfectly!

  2. George Avatar

    Thanks for sharing this post Brad. It is really usefull! I just have a question and you may can help me. I dont think it’s the best idea to repeat it here, you can see that at studiopress forums 🙂

    studiopress.com/forums/topic/last-modification-date-publish-date/

    1. George Avatar

      How about showing the modification date which will replace the publish date, or show the publish date if there’s no modification date? Will i need a completely new code?

      1. Brad Dalton Avatar
        Brad Dalton

        Yes or modify the code to do that.

  3. Hi Brad, and thank you very much for sharing this super useful code.

    Is there any way to apply “Remove Original Date & Show Updated Date Only” for all posts EXCEPT those of certain categories or even a single one whose posts would display both the original date and the updated date if applicable?

    1. Brad Dalton Avatar
      Brad Dalton

      Sure is Alex. You can use code to remove the date conditionally and then use this code to display the updated date only with or without conditionals.

  4. Thanks for your help. I was able to get it to say what I wanted to say.

    Last updated: Wednesday, November 6, 2013 .

    At this rate, I am learning more and more about Genesis hooks on my blog. lol

    Ok, off to find the next thing to customize for this weekend. Have a good night Brad.

    1. Brad Dalton Avatar
      Brad Dalton

      No worries Derek

  5. I uninstalled Simple Edit’s and still no chage. hmm..
    I’m in the magazine pro theme. I may have to work on this during the week. It’s 1a.m. and eyes are failing me.

    1. Brad Dalton Avatar
      Brad Dalton

      Know the feeling well.

      1. With simple edit’s still uninstalled, could not get it to work. I’m not a programmar so I removed this and will see if there is a plugin then. I guess another plugin I am using his same hook’s.

        1. Brad Dalton Avatar
          Brad Dalton

          Which code snippet are you using?

          1. Brad, I seem to have took a different approach to doing this. I got it working minus now trying to remove the actual time that is added to the last updated date in the posts now.

            I used this plugin: http://wordpress.org/plugins/last-updated-shortcode/faq/

            Then added: [lastupdated]

            To this code in my functions PHP file: http://my.studiopress.com/snippets/post-info/#customize

            The usernames still go to there archive which is what I wanted. I took a different approach but seems to be working minues removing the time in the post info.

          2. Brad Dalton Avatar
            Brad Dalton

            Good stuff.

            You can remove the time by changing the time format and/or using CSS or PHP code.

  6. I added that code and it works find Brad, but the username’s if clicked on get redirected to there homepage they have listed in there profile.

    Does the code above in your post not link the username to there user archive? I have the simple edits plugin installed and have this on first line: [post_date] By [post_author_posts_link] [post_comments]

    1. Brad Dalton Avatar
      Brad Dalton

      Hello Derek

      The code and the plugin use the same hook so it might not work.

      Try using one at a time rather than both.

      You could also remove the author link or modify the code.

  7. Les Campbell Avatar
    Les Campbell

    I tried the above mentioned code and it did not remove the original line. It now shows as follows:

    September 5, 2013 By Les Campbell · Leave a Comment · (Updated: September 7, 2013)

    September 5, 2013 By Les Campbell Leave a Comment (Edit)

    1. Brad Dalton Avatar
      Brad Dalton

      Hi Les.

      Yes, that’s the way it works. It shows the original date and the updated date.

      I also added code which only displays the updated date if that’s what you want.

      1. Les Campbell Avatar
        Les Campbell

        The post page displays two lines at the top of the page after I added the code you mentioned. The 1st line would displayed is your code and the 2nd line dissplayed is the default code. I did some research on the code you provided and discovered if I add “,12” to your code this eliminates the 2nd line to the post page. Here is the code that corrected the problem:

        remove_action( ‘genesis_entry_header’, ‘genesis_post_info’,12 );

        ================================================
        September 5, 2013 By Les Campbell · Leave a Comment · (Updated: September 7, 2013)

        September 5, 2013 By Les Campbell Leave a Comment (Edit)
        =================================================

        The code I provided removes the default line that is being displayed. I now have the correct line showing the post pages as follows:
        ================================================
        September 5, 2013 By Les Campbell · Leave a Comment · (Updated: September 7, 2013)
        ================================================

        1. Brad Dalton Avatar
          Brad Dalton

          Thanks for sharing this Les.

          I did see the post info being displayed twice as you mentioned once i added the code locally so i appreciate your solution and will add this to the code in this post.

          I wrote about the 3rd parameter for positioning priority a while ago which enables you to use different functions with the same hook in different positions.

          If you don’t add the 12, then you don’t remove the default post info from the default position therefore it remains and you add back the new updated post info as well.

  8. I use the News theme which already has a filter on that part, so I had to incorporate it into the filter:
    [code]
    add_filter( ‘genesis_post_info’, ‘post_info_filter’ );

    function post_info_filter($post_info) {

    if ( !is_page() ) {

    $post_info = ‘[post_date] Written by [post_author_link], [post_comments] [post_edit]’;
    $published = get_the_date( ‘F j, Y’ );
    $modified = the_modified_date( ‘F j, Y’, ”, ”, FALSE );
    $published_compare = get_the_date( ‘Y-m-d’ );
    $modified_compare = the_modified_date( ‘Y-m-d’, ”, ”, FALSE );
    if ( $published_compare < $modified_compare ) {
    $post_info = $post_info . '· (Updated: ‘ . $modified . ‘)‘;
    }
    return $post_info;

    }}
    [/code]

    1. Brad Dalton Avatar
      Brad Dalton

      Thanks Chris.

      I tested your code and it works perfectly.

      Thanks for sharing your solution.

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.