1

Okay, so I have googled this for the past few hours and even though I am getting closer, I am still stuck.

Problem: If I posted an article on December 15th 2016 but I NOW I updated the same article today(July 20th 2017), when you view the article, the updated/modified date is never shown to the user.

NOTE: I did google it and I am able to display the modified date thanks to articles on WPBeginner etc BUT, how do I only post ONE? If the post is updated, it should post JUST the new modified date/time, not both.

I was leaning towards IF and ELSE statements but I can’t figure out how to set it up like this…

* If post was modified, post modified date, else post date it was published. *

If someone can please help me out here, I would appreciate it a lot, I am lost, thanks!

  • how about posting the code? kinda hard to help you with your code without seeing it – Mark Kaplun Jul 30 '17 at 14:12
  • Hey Mark, thanks for replying. Issue is I am lost and don't really know where to start. '<?php the_author_posts_link(); ?> &middot; <?php the_time(get_option('date_format')); ?></p>' This is the code that I need to be replaced with 'get_the_modified_time' if the post is updated otherwise return to the original code. – KD35 Jul 30 '17 at 16:52
  • This depends on theme. You can use themes provided hooks to modify the UI. – hkchakladar Jul 30 '17 at 20:03
1

You just need to compare values of get_the_post_time() and get_the_modified_time().

if ( get_the_post_time() == get_the_modified_time() ) {
    // Published on...
} else {
    // Modified on...
}
  • Alright, thanks this is what I need, I will try this and report back, thanks again for the head start! – KD35 Jul 30 '17 at 19:35
  • I did it!! Thanks a lot Belinus and everyone who replied! – KD35 Jul 31 '17 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.