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
- Define custom Page Template without its own .php file
- 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
- Implementing DNS Prefetching with WordPress
- How can I tell if I’m on a login page? [duplicate]
- In WooCommerce I need to modify the thankyou.php page [closed]
- Why get_header() or get_footer() does not run twice if called in the same php file?
- 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)
- Adding WooCommerce to a Custom Theme – not working [closed]
- WooCommerce add_action hook results in 500 error
- 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]
- 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?
- Get current page_id before loop, in functions.php
- How to properly add function called by action-hooked function to functions.php?
- “is_new_day()” alternative for years?
- Inserting a functions output after the content
- Add function to every post?
- Don’t delete a page if it holds users
- Passing values from a widget to a function within a plugin
- How can I get my Script to work on the Login page?
- 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?
- 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… )
- Why doesn’t is_page(id) work in functions.php?
- jQuery does not work
- Why does re-using this function not work? [closed]
- Override the WordPress core function wp_referer_field
- How to return hook data when multiple parameters are present?
- What is the text that appears beside the page titles in the list of pages in the WP admin?
- How to edit the Tags within the image file URLs?
- Control the srcset much more (not all sizes in it each time)
- The Loop not looping?
- How to add_filter html template to middle of content
- While loop with an exception after a count is reached
- Auto log in hook is requiring a page refresh
- How do I pull excerpts from pages?
- Output loop to function return?
- Possible to hook into Media Library preview File column and use a custom image?
- Add back in child theme what the parent theme removed with remove_action
- Writing a function to detect an event
- Problem with calling custom function in a foreach loop
- WordPress wraps span tags into p tags
- Get term slug by term id and then explode it
- Using functions.php to include code that’s processed inline
- Changing where my author box is printed
- Add Adsense code between job listings – wp job manager plugin
- Replace admin header logo with an image
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- is_home() not working in functions.php file
- How to place a div inside a function that creates a div
- Simplest Way to Build Custom Archives Page?
- Filter for replacing the WP_query object for a given category
- wordpress built-in Jalali date convertor
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Does hook have an effect on increasing the page load?
- What is the earliest Hook a Script can use?
- Populate acf-field, depending on block name
- How Do I Unhook This Parent Theme Function?
- Calling hooks in functions
- How to use `foreach()` in ajax call
- How to add custom column into custom post, when field is select
- Code executes outside of Loop while same code gives ‘Uninitialized string offset’ notice inside a while loop
- Only seems to be displaying one child when there are supposed to be multiple
- How to echo the translated custom field?
- Integrate WP Tiles into existing loop (index.php) and theme
- Check if excerpt is empty at loop-portfolio
- Why wp_ajax hooks doesn’t work?
- Why don’t some template tags work when querying information on single.php?
- How can I append and prepend something to all post hyperlinks without using ::before or ::after? PHP hook solution?
- how to handle multiple forloop?
- Parse error: syntax error, unexpected ‘endforeach’ (T_ENDFOREACH) in [closed]
- How do grab the main loop, with conditions, and output via shortcodes
- Why functions metaboxes is causing White Screen in Admin [closed]
- How do I add functionality to images?
- 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
- 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]