Loosely what you have should work already. However few things are off.
- Calling these function without time format will produce values like
1:36 pm
(depending on your site’s settings), which are not exactly comparable. - Post modified time can be less than published in some cases, like scheduled posts.
So I would write it along the lines of:
if ( get_the_modified_time( 'U' ) > get_the_time( 'U' ) ) {
echo 'Last updated:' . get_the_modified_time();
}
U
format stands for a numeric Unix timestamp, which is comparison–friendly.
Related Posts:
- Issues with title-tag and document_title_parts
- Import WordPress XML File from Within Functions.php
- Define custom Page Template without its own .php file
- Does hooking into the same action multiple times drain memory?
- How to influence the information displayed on widget inside wp-admin
- Extract image from content and set it as the featured image
- Is there a hook or function I can use to display all theme files being used on a current page?
- Issue with get_theme_mod returning a blank value instead of the saved value
- Add action hook conditionally – only when home.php in use
- why doesnt is_home() work in functions.php
- How to create thumbnails for PDF uploads?
- AJAX handler throws 400 (Bad request) – why?
- Implementing DNS Prefetching with WordPress
- Help me to understand wp_header() and wp_footer() functions
- How can I tell if I’m on a login page? [duplicate]
- In WooCommerce I need to modify the thankyou.php page [closed]
- How can I add an extra WooCommerce hook
- Why get_header() or get_footer() does not run twice if called in the same php file?
- change the comment time output to: X time ago instead of actual date and time
- How to display the_post_thumbnail if a post has one or otherwise display the first image in a post?
- Remove Page Title from Static Frontpage
- How to override WordPress registration and insert an auto-generated username?
- Most elegant way to enqueue scripts in function.php with foreach loop
- Set default options for inserting media
- Change parent theme file function in child themes functions.php
- Adding extra SVGs to TwentyNineteen child theme using class TwentyNineteen_SVG_Icons
- How to hook into the quick edit action?
- gform_after_submission content appears immediately after , not in post body [closed]
- How do I change parameters without changing the core
- WordPress – thumbnail image from youtube (function and loop)
- Is it possible to be more page/post specific with admin_enqueue_script?
- Adding WooCommerce to a Custom Theme – not working [closed]
- WooCommerce add_action hook results in 500 error
- Issue adding text after short description on product pages Woocommerce [closed]
- Customize “the_posts_pagination” and put list instead div
- A snippet after every image
- Function to show only first instance of shortcode
- Automatically insert php function into post $the_content
- Creating loop within functions.php
- Display WooCommerce subscriptions for user [closed]
- How to use max and min values of custom fields
- Increment price for Woocommerce Minicart [closed]
- how to change link of some wordpress pages
- Gravity Forms field entries into wp_query loop [closed]
- Post thumbnail relative link and HTML modify
- Custom Shortcode, functions PHP WP_Query loop
- Filtering posts by category name based on page’s slug
- Proper way of using functions in action hook?
- How to preserve edits to Name or Slug of term when using wp_update_term on save?
- Accepted arguments value in hook functions
- Get current page_id before loop, in functions.php
- 2 Loops, Only Displaying 1 Loop in Both Loops
- How to properly add function called by action-hooked function to functions.php?
- Which action hook to use for function?
- Change size and crop medium_large images
- Gravity Forms – Using a Form to Pre-populate A Gravity Form [closed]
- “is_new_day()” alternative for years?
- Running a script before absolutely everything
- Inserting a functions output after the content
- How to display post content instead of excerpt
- Add function to every post?
- Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘greenday_head’ not found or invalid function name
- Modify a function without editing template
- Don’t delete a page if it holds users
- Problem only while using require_once() within functions.php
- Passing values from a widget to a function within a plugin
- Having a Function Inside of the Loop
- Which action does wp_update_user triggers?
- Getting different functions data while using while loop in wordpress
- How can I get my Script to work on the Login page?
- Trigger a custom function when option are saved in admin area
- Execute a ultimate member action when user role is updated
- Create a new query in function.php to filter blog posts
- Add other social networks to TwentyNineteen_SVG_Icons class in child theme?
- How to use wp_trash_post (or wp_delete_post) for deleting a (or all) post(s) from custom post type?
- What did I do wrong in my functions code, that will not change the “Get New Password” text to “Send It”?
- Limit length of first excerpt in the loop
- Replace a menu with widget or a custom template file programmatically
- Footer disappears when using the_content ( )
- Default Custom Field Value Automatically Update
- Multiple Loops Meta Data
- Get User Login Data (date, time… )
- Registration Hooks don’t appear to be working
- Why doesn’t is_page(id) work in functions.php?
- jQuery does not work
- Why does re-using this function not work? [closed]
- Pass parameter to hooked function using custom page template
- Override the WordPress core function wp_referer_field
- Creating mixture of shortcodes to use in the visual/text editor
- image_size with respect to aspect ratios
- Get full slug for a WordPress Post
- Update post meta with wp cron
- delete_term is not working properly with add_action()
- Get category of post inside save_post hook
- Create section wit form
- Log in and out using custom pages, no logout confirmation and redirects for logging in and out 2023
- Copy and Modified WooCommerce function is_coupon_valid [closed]
- Function attached to cron job not running but will run if called manually
- How can I able to exclude ‘Category’ and ‘Tag’ slug from the URL in WordPress without reloading to new site?
- Redirecting after login except for a specific page