Try this:
$q = new WP_Query;
$posts = $q->query( array(
'posts_per_page' => 1,
'orderby' => 'post_modified', // Sorts by the date modified.
'order' => 'DESC', // Sorts in descending order.
'no_found_rows' => true,
) );
// Note that $posts could have more than one post, if your site have sticky
// posts. However, the first post, unless filtered by plugins, would always
// be the most recently modified/updated one.
if ( ! empty( $posts ) ) {
$post = $posts[0];
setup_postdata( $post );
?>
<p>Most recent site update: <?php the_modified_date( 'F d, Y' ); ?>.</p>
<?php
wp_reset_postdata();
}
Related Posts:
- Keep featured content post in homepage with original order
- How to show related posts by category
- Display all posts from specific categories on a page
- How to schedule multiple posts while adding new
- How to exclude latest x posts from a paginated query?
- Display content from a specific category
- How to display posts by current user/author in a custom page template?
- Number of posts per page setting is not working?
- WordPress Posts Out Of Order after 3.1 Update
- Can’t show comments count per post outside loop
- Order post by year DESC and month ASC
- WordPress get posts by date without query_posts
- Featured Posts for Category Pages
- Cannot Update A Post, 404 Error
- Function to show random posts from a category
- How to insert current date/time in the content of a post?
- Hiding posts in a list from specified categories
- Improving WP_Query for performance when random posts are ordered
- Create dropdown list post
- I would like to give special promotion for the first 100 posts in my blog? Can anyone tell me how to do that?
- Inserting custom data to the_post() during loop
- How To Get Posts With A Specific Word
- If modified on same day, show only time
- Why WP_Query(‘showposts=5’) shows only 1 post?
- is there a way to show the the post title after the image?
- Why is querying posts messing up my pages?
- Display all posts that were published before full post on single.php
- Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files
- Random ajax load only works with posts_per_page set to -1
- Prevent scheduled post being published if date/time is past current date/time
- Multi row post list
- posts_per_page option limits the number of Gallery items
- How i can limit period of post publication?
- Order posts alphabetically: how to set order=asc in mysql query?
- How to order posts in an arbitrary order?
- Nested WP_Query breaking loop
- WordPress query_posts by tag doesn’t work anymore(?)
- While loop articles – if statement order
- do more action after I publish a post
- Retrieve only posts from a specific user in wp-admin/edit.php
- WordPress website loads more posts than expected
- Changing default WP-Site creation date
- query post limits
- Display Posts with template on a Page
- Query for first 3 posts to change the look and feel
- How to check in functions.php if there is data in a WP_Query?
- Shortcode with ‘year’ parameter
- Post Filtering by GET URL parameters
- On what hook can I get the queried object’s final state?
- How to give classname to post if post has no content?
- tribe_get_start_time displays the current date and time on other post types than tribe_events
- Get post by tag
- How to show different timestamp
- All categories displays the same posts
- Query function not executed between element [closed]
- Echo the number of posts being displayed
- Exclude a category of posts in author template
- WordPress query portfolio posts
- Display specific posts on home page
- How to get posts ordered by using their categories?
- Access last visit time to a post
- WP_Query articles order by offset in collumns
- Display 3 posts with different HTML markup using a loop
- Getting posts from some categories plus some individual posts
- Get posts from current category?
- How to assign a post to a post parrent?
- get parent fields title, content excerpt etc
- Post navigation using date
- AWS usage queries
- Bulk update published posts date randomly using wp-cli?
- Move position in post list for a custom checkbox column
- How to merge the content of posts that have the same title?
- Show posts from two specific category in WP_Query
- How to fetch courses in all languages in WordPress?
- How can I use query_posts to loop through posts and construct my own content?
- Assign a day of the week to post, e.g: Assign Monday to post and have it only appear when the day is Monday
- Show 5 posts and than 3 posts offset with pagination
- wp_query args with relation
- Querying posts from current category, using a variable as array argument
- Use special template for the first post in the loop
- Repeating post how to solve this
- Need help writing loop to display posts by categories in separate divs
- Modify WordPress loop after it has been run
- Query post category & remove any post id
- show latest authors blog post
- How to get only current images of a post
- Ordering posts alphabetically by meta keys and title
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- Why I have this strange behavior when I try to exlude the featured post from posts visualization?
- Remove duplicated posts in the loop if post has more than one category
- How to limit the number of results for all query_posts on mysite
- wp_query select if have comments
- Creating pages and getting their values from the database table
- How to limit post query to only return a total count of items with certain post statuses?
- Not displaying any articles on a custom made file
- query_posts different amount of posts per page [duplicate]
- Do I need to create a multisite for querying posts from multiple WordPress sites?
- Sort Posts Alphabetically Based on Specific Category (Divi)
- How to change url of posts?
- date_query returning only the most recent post instead of the post published before today