Function Name: get_the_modified_date
In WordPress, the get_the_modified_date
function is used to retrieve the last modified date of a specific post or page. This function returns the date as a formatted string, which can be customized using the provided parameters.
The get_the_modified_date
function is particularly useful in scenarios where you want to display the date when a post or page was last modified. This can be helpful for visitors to track the freshness or relevance of content, especially in cases where information might change over time.
Example Usage:
Let’s say you have a blog post and you want to display the last modified date within the post’s content. You can utilize the get_the_modified_date
function to achieve this. Here’s an example of how you can use it:
<p>Last modified on: <?php echo get_the_modified_date(); ?></p>
In the above example, the function get_the_modified_date
is used to retrieve the last modified date of the current post. The returned date is then echoed within a <p>
element to display it as "Last modified on: [date]".
You can also customize the formatting of the date by passing additional parameters to the function. For instance:
<p>Last modified on: <?php echo get_the_modified_date('F j, Y'); ?></p>
In this modified example, the date is formatted as "Last modified on: [Month Day, Year]".
Remember, the get_the_modified_date
function only retrieves the date but does not actually display it. You need to use echo
or assign it to a variable and then display it using appropriate HTML markup.
So, next time you need to display the last modified date of a post or page in your WordPress website, make use of the get_the_modified_date
function and provide your visitors with up-to-date information.