© 2024 fjorge. All rights reserved.
How do I iterate through recently modified posts in Wordpress?

I have a client who has a WordPress installation with thousands of pages. There are a couple things wrong with this, mainly relating to speed and editing practicality. It's also an issue to find pages because they are ordered hierarchically. There are a few pages I modify fairly regularly and wanted a convenient way to find them. In order to do so, I needed to iterate through recently modified pages. Here's what I came up with:
The query gets the last 25 posts of type page ordered by post_modified. From there, a foreach loop through the result yields individual posts in object form. Then I used the post's permalink, stripping off the site_url() as the text for the edit_post_link() text. All is well. I'll soon publish the plugin which adds the list to the admin dashboard.