The Pods plug-in for WordPress (https://pods.io) is some stunning—and FREE—software. In one instance, I’m using it with a custom post type for job openings. One of the requests was to have the page with the job listings show a “last modified” date. This was a head-scratcher at first, because the listings part of the page is pulled in from the custom posts via Pods, while the rest of the page is regular html. The whole point was to avoid having the job listings editor update the “last modified” date manually after any post was edited or added. If a job was added/updated/edited in any way, only that job would have its “last modified” date changed—it wouldn’t affect the listings page because no code was actually being changed there.
I’m using a Pods shortcode to pull in the listings, with the most recent posts listed first. The -1 indicates that all listings should be shown:[pods name="job" orderby="date_posted DESC" limit="-1"] insert listing text & fields here [/pods]
After a bit of thinking, I realized how easy it would be to add the date automatically, simply using a variation of the shortcode above. One of the built-in fields to every post is “post_modified” which is a date/time stamp. Therefore, using this code: Last updated/edited on [pods name="job" orderby="post_modified DESC" limit="1"] {@post_modified} Eastern.[/pods]
, it will sort the dates when all the posts were modified, put them in reverse order, and return only the first one (thereby giving the last date any modification was done). This is a pretty slick, straightforward solution.
I don’t know how (i.e., I haven’t cared to pursue the research of how) to parse the date/time to print it out a little more elegantly, but, for now, this is quite good enough.
Thanks, Pods people! ◼︎