This thread is resolved. Here is a description of the problem and solution.
Problem: I would like to show the last modification date for a specific post using a custom shortcode, but when I update the post with Forms the date does not seem to change.
Solution:
Be sure the shortcode is set up to accept a post ID shortcode attribute, since it is placed on a different post.
I have Custom Post Type and Custom Fields in it.
I modify the posts using CRED form and I need to print out modyfication date.
I do not always update the post body, sometimes only one of the Custom Fields is updated.
I have no idea how to do it. Maybe there is some PHP code to insert into the file?
This is very important to me, because user visiting the website must see the date and time of modification of the post.
I will be grateful for every hint.
Unfortunately, this code does not work as I would like.
I've already inserted the code directly into the template files:
the_modified_date('j F Y H:i:s')
This code works the same as the code from you:
The date and time of the modification is changed when you edit the post directly in WordPress.
But when you edit a post while in the custom form built in the Toolset, the date and time are no longer refreshed.
Hi, Shane is on vacation this week so I will try to help.
But when you edit a post while in the custom form built in the Toolset, the date and time are no longer refreshed.
Even if you only modify a custom field value, CRED should update the post modification date and time to reflect that change. If this is not happening on your site, I will need to take a closer look.
May I see this Form on your site to understand how it is implemented? If that's okay, please provide login credentials in the private reply fields here. Let me know which Form you are referring to, and where I can see the Form on your site. I will also need to know where you added this code in your template PHP files.
Okay check now. There were two problems:
1. The wp_last_modifed shortcode was placed on the page Tabelka Gdańska 26, so it was showing the last modified date for Tabelka Gdańska 26, not the last modified date for Edycja walut. I updated the shortcode in Tabelka Gdańska 26 to supply the correct post ID as a shortcode attribute:
[wp_last_modified id="15"]
2. The wp_last_modified shortcode was returning the_modified_date, but should return get_the_modified_date instead. This is why you had to place the shortcode after the View, which seems backwards. I made this change for you, and moved the shortcode before the View where it should be:
return get_the_modified_date('j F Y H:i:s', $atts['id']);
It works beautifully! Yes, I've mixed up the place to embed the code, stupid mistake 🙂 Thank you very much Christian! Without your help, I would probably work on the problem for a very very long time. And there is the case of the_modified_date and get_the_modified_date. It's great to have such support as here on the Toolset Forum. Thanks again!