Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Add a date updated/date modified option using custom fields

Adding a custom field to conditionally display last modified date:

You can use the built-in custom fields metabox of your post. Usually it is hidden by default, so you have to enable it going to ‘Screen Options ‘ and checking the ‘Custom Fields’ box like this:

enter image description here

If you’re using the new block editor, you’ll find the option by going to the Edit Post Screen > Click the three dots button on the top right corner > Settings > Advanced Panels.

Now, add a new custom field, let’s call it show_last_modified and set it to true.

enter image description here

Displaying the last modified date:

The function the_modified_date() will give you the date on which the post was last modified.

To display it, seems that you will have to override the mh_magazine_post_meta() function.

function mh_magazine_post_meta() {
    $mh_magazine_options = mh_magazine_theme_options();
    if ($mh_magazine_options['post_meta_date'] === 'enable' || $mh_magazine_options['post_meta_author'] === 'enable' && in_the_loop() || $mh_magazine_options['post_meta_cat'] === 'enable' && in_the_loop() && is_singular() || $mh_magazine_options['post_meta_comments'] === 'enable') {
        echo '<div class="mh-meta entry-meta">' . "\n";
            if ($mh_magazine_options['post_meta_date'] === 'enable') {
                echo '<span class="entry-meta-date updated"><i class="fa fa-clock-o"></i><a href="' . esc_url(get_month_link(get_the_time('Y'), get_the_time('m'))) . '">' . get_the_date() . '</a></span>' . "\n";
                // Custom code

                if(!empty(get_post_meta(get_the_ID(), 'show_last_modified', true)){
                   echo 'Last modified date:' . the_modified_date();
                }

                //
            }
            if ($mh_magazine_options['post_meta_author'] === 'enable' && in_the_loop()) {
                echo '<span class="entry-meta-author author vcard"><i class="fa fa-user"></i><a class="fn" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span>' . "\n";
            }
            if ($mh_magazine_options['post_meta_cat'] === 'enable' && in_the_loop() && is_singular()) {
                echo '<span class="entry-meta-categories"><i class="fa fa-folder-open-o"></i>' . get_the_category_list(', ', '') . '</span>' . "\n";
            }
            if ($mh_magazine_options['post_meta_comments'] === 'enable') {
                echo '<span class="entry-meta-comments"><i class="fa fa-comment-o"></i>';
                    mh_magazine_comment_count();
                echo '</span>' . "\n";
            }
        echo '</div>' . "\n";
    }
}

add_action('mh_post_header', 'mh_magazine_post_meta');

Place the above code on your child theme and customize the markup to suit your needs.

Related Posts:

  1. what is the correct way to compare dates in a WP query_posts meta_query
  2. Meta keywords and descriptions plugin for manually editing meta for each page/post
  3. How to remove Profile Picture section or the message “You can change your profile picture on Gravatar.”
  4. Manipulating post meta in the customizer
  5. Add field to posts (checkbox) that only one post can have
  6. generate unique number when registering a user
  7. How to get value from custom backend menu
  8. ajax delete value from custom field array
  9. Allow Users to Set Password During Registration
  10. Custom protected password page with ACF
  11. Passing page url into a custom field via the Press-This bookmarklet
  12. How to extend nav-menu-item-control data in Appearance > Customize?
  13. Custom column sorting in WordPress admin post table
  14. Hide custom field if empty
  15. Query posts by category AND custom field, then ORDERBY another custom field – help!
  16. list/consult Taxonomy only for the respective author/creator in dashbboard
  17. Setting custom search engine indexing for a “dynamic WordPress page” with htaccess
  18. Advanced Custom Fields: Sorting custom columns with custom fields sorts only by date
  19. Access post meta in future_to_publish function
  20. How to change popular term checklist title when edit post?
  21. How to add textarea field to taxonomy (tag)?
  22. Get Custom Logo Alt Text
  23. How to add an extra button on woocommerce shop page and use it to send the product info with image in a mail? [closed]
  24. Woocomerce custom billing address fields display in order details [closed]
  25. result from custom filter admin table list backend does not work
  26. Manage multiple domains from one backend
  27. What requirements for ACF custom fields key and name properties?
  28. How to insert a writing panel between the title and the page content?
  29. Two description meta tags All in One SEO WordPress [closed]
  30. Customize rel=canonical tag for single blog post
  31. Toggle custom fields?
  32. Let’s Create Custom Field Template Documentation
  33. How to print Array values of custom Fields Meta?
  34. Get users based on month ACF datepicker field
  35. What is the best way to modify Admin Panel on WordPress?
  36. if in category but only with post meta
  37. how to make a custom field readonly or disabled by user role?
  38. theme customizer – can a single option pass multiple values?
  39. Let author add field to metabox by pressing a button
  40. How to auto add nofollow to links in custom field?
  41. Best way to achieve multiple links in a post title
  42. How to replace blog page url with subdomain at all places, even in xml sitemap?
  43. Is it possible to add custom badges to product attributes conditionally, based on custom field?
  44. How to get Previous Visited Page Information
  45. WordPress category custom title
  46. No plugin populate user information in to form
  47. How can Use custom input field in functions.php page?
  48. Simple custom attributes on posts
  49. Use a custom page with dynamic content as a user profile page
  50. Query Product categories what have a custom field
  51. Custom Meta Box: Value saved in WordPress DB, but not shown in input field on Edit Screen
  52. Conflict between Yoast SEO and my custom theme
  53. Adding a drop-down (select tag) option under Menu Settings in WordPress Admin
  54. How to Disable option of meta field if that option is selected for any other post in custom post type?
  55. Replace publish date in blog module with custom field
  56. How do I enable the text editer in my WordPress theme? [closed]
  57. How to add H1 Tag on Homepage?
  58. Add commentmeta custom field to every published comment with SQL
  59. Does WordPress support template resources/custom fields
  60. Change post template the proper way
  61. Create a google friendly header with text and logo
  62. When post is updated, custom metadata in text area field is overwritten
  63. Adding custom fields to images
  64. Save And Display Mp3 Audio files on WooCommerce product page with Dokan
  65. Advice how to connect custom database with WordPress, change data in WordPress and finaly use this data
  66. Add custom information in editor summary
  67. Customise “Add a New Post” page
  68. How to: Easily Move a WordPress Install from Development to Production?
  69. Is there a flowchart for WordPress loading sequence?
  70. Essential technical features for high-end WordPress web hosting? [closed]
  71. How to remove admin menu pages inserted by plugins?
  72. How to put logs in WordPress
  73. How to filter post listing (in WP dashboard posts listing) using a custom field (search functionality)?
  74. How to get the Date Format and Time Format settings for use in my template?
  75. Explanation of update_post_(meta/term)_cache
  76. Can I exclude a post by meta key using pre_get_posts function?
  77. Advanced search form with filters for custom taxonomies and custom fields
  78. How to update custom fields using the wp_insert_post() function?
  79. Add validation and error handling when saving custom fields?
  80. Where are Additional CSS files stored
  81. Can wp_query return posts meta in a single request?
  82. Best Practices for Regression Testing WordPress Websites?
  83. Remove wrapping div and ul from output of wp_nav_menu
  84. Attaching taxonomy data to post with wp_insert_post
  85. What Is The Use Of map_meta_cap Filter?
  86. get post author id outside loop
  87. Custom Walker: how to get ID in function start_lvl
  88. Creative uses of WordPress [closed]
  89. How to *remove* a parent theme page template from a child theme?
  90. Validating Custom Meta Box Values & Required Fields
  91. How do I make my child theme re-apply the settings that were customised when its parent was active?
  92. Multiple Inputs in a Customizer Control
  93. New WP_Customize API – how does it work under the hood?
  94. Embedding a SOAP Client into a WordPress Plugin?
  95. Is there anything that Joomla or Drupal can do that can’t be done in WordPress? [closed]
  96. Update widget form after drag-and-drop (WP save bug)
  97. Data sanitization: Best Practices with code examples
  98. How to benchmark a WordPress installation? [closed]
  99. don’t publish custom post type post if a meta data field isn’t valid
  100. Should I delete the default themes?
Categories customization Tags custom-field, customization, post-meta, seo
How to automatically nofollow a set domains? (I seem to have half of the answer)
How to get WordPress to send Password Reset Link Email instead of New Password?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress