Title: Last updated date function
Last modified: December 19, 2018

---

# Last updated date function

 *  Resolved [凱寧](https://wordpress.org/support/users/kennyateam990/)
 * (@kennyateam990)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/last-updated-date-function/)
 * I want to show the “last updated date” on the front of the post and page.
    so
   I add the following code in the functions.php file.
 *     ```
       function wpb_last_updated_date( $content ) {
       $u_time = get_the_time('U');
       $u_modified_time = get_the_modified_time('U');
       if ($u_modified_time >= $u_time + 86400) {
       $updated_date = get_the_modified_time('F jS, Y');
       $updated_time = get_the_modified_time('h:i a');
       $custom_content .= '<p class="last-updated" style="text-align:right">Last updated on '. $updated_date . ' at '. $updated_time .'</p>';
       }
           $custom_content .= $content;
           return $custom_content;
       }
   
       add_filter( 'the_content', 'wpb_last_updated_date' );
       ```
   
 * It works,it show on every page.
    but I don`t want to show it on my home page.
   How can I do ?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Howdy_McGee](https://wordpress.org/support/users/howdy_mcgee/)
 * (@howdy_mcgee)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/last-updated-date-function/#post-11008260)
 * You can use [WordPress Conditional Tags](https://developer.wordpress.org/themes/basics/conditional-tags/)
 * At the top of your function you can return early if a condition is met. If you
   have a front-page set you can say:
 *     ```
       if( is_front_page() ) {
           return $content;
       }
       ```
   
 * Returning early would prevent your additional code from running.
 *  Thread Starter [凱寧](https://wordpress.org/support/users/kennyateam990/)
 * (@kennyateam990)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/last-updated-date-function/#post-11010412)
 * It works! thanks a lot!!!
 *  Thread Starter [凱寧](https://wordpress.org/support/users/kennyateam990/)
 * (@kennyateam990)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/last-updated-date-function/#post-11010860)
 * [@howdy_mcgee](https://wordpress.org/support/users/howdy_mcgee/)
 * and another problem,how do I display after content ? not before content.
    -  This reply was modified 7 years, 5 months ago by [凱寧](https://wordpress.org/support/users/kennyateam990/).
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/last-updated-date-function/#post-11013771)
 * Switch your code around
 *     ```
           $content .= $custom_content;
           return $content;
       ```
   
 *  Thread Starter [凱寧](https://wordpress.org/support/users/kennyateam990/)
 * (@kennyateam990)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/last-updated-date-function/#post-11014947)
 * oh !! I see thanks !!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Last updated date function’ is closed to new replies.

## Tags

 * [functions](https://wordpress.org/support/topic-tag/functions/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 5 replies
 * 3 participants
 * Last reply from: [凱寧](https://wordpress.org/support/users/kennyateam990/)
 * Last activity: [7 years, 5 months ago](https://wordpress.org/support/topic/last-updated-date-function/#post-11014947)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
