You can retrieve the modified date of a WordPress page using a variety of methods. Here are some common approaches:
Using the WordPress Admin Dashboard
- Navigate to the Pages section: Log in to your WordPress dashboard and click on "Pages" from the left-hand menu.
- Locate the desired page: Find the page you want to check the modified date for.
- View the page details: Click on the page title to open the page's edit screen.
- Check the "Modified" date: Look for the "Modified" field on the right side of the edit screen. It will display the date and time the page was last modified.
Using the WordPress REST API
The WordPress REST API offers a programmatic way to access page data, including the modified date.
- Make a GET request: Use a tool like Postman or curl to send a GET request to the following URL:
https://your-website.com/wp-json/wp/v2/pages/<page-id>
Replace
your-website.com
with your actual website address and<page-id>
with the ID of the page you want to retrieve. - Parse the response: The response will be a JSON object containing the page details, including the
modified
field representing the last modified date and time.
Using PHP Code
You can use the following PHP code snippet to retrieve the modified date of a page within your theme or plugin:
<?php
$page_id = 123; // Replace with the ID of the desired page
$page = get_post($page_id);
$modified_date = $page->post_modified;
echo $modified_date;
?>
This code first retrieves the page object using get_post()
and then accesses the post_modified
property to get the last modified date.
Using WordPress Plugins
Several plugins can display the modified date of a page on the frontend of your website. Some popular options include:
- Post/Page Modified Date: This plugin allows you to display the modified date of a page or post in various formats.
- Simple Custom Post Types: This plugin provides a simple interface to create custom post types and display their modified dates.
By choosing the method that best suits your needs, you can easily access the modified date of any WordPress page.