-
AuthorPosts
-
November 4, 2019 at 2:20 pm #1153701
I am curious on how I can add a timestamp to a page, so it informs the user when the information has been updated? I would like to place it in the header area of my side https://bladeelectionresults.com/.
Can this be done?
Thanks,
KfranckNovember 4, 2019 at 4:10 pm #1153720Hi,
Please add following code to bottom of your child theme functions.php file in Appearance > Editor
// Display update time function wp_get_updated_date(){ $u_time = get_the_time('U'); $u_modified_time = get_the_modified_time('U'); if ($u_modified_time >= $u_time + 86400) { echo "<p>Last modified on "; the_modified_time('F jS, Y'); echo " at "; the_modified_time(); echo "</p> "; } } add_shortcode( 'update_time', 'wp_get_updated_date' );
Then add following shortcode to display it
[update_time]
If you would like to add a widget area to header and to display it there, please refer to this post – https://kriesi.at/documentation/enfold/header/#adding-a-header-widget-area
Best regards,
YigitNovember 4, 2019 at 4:58 pm #1153725Yigit:
I found a function-enfold-php. Is that the place I add the “//Display update time” code?
Also, If I don’t add a widget area to the header, where will the time stamp by displayed?
Thanks,
KfranckNovember 4, 2019 at 6:42 pm #1153746I found the function.php file and added the code you recommended.
I then created a header widget, adding this text in the header widget — Updated at [update_time].
However, the timestamp does not show. Could it be located under the logo? I did something wrong. Suggestions?
Thanks,
kfranckNovember 5, 2019 at 11:26 am #1153945Hi,
I updated the code in bottom of functions.php file to following one
//-------------------------------- // Header widget area //-------------------------------- add_action( 'ava_after_main_menu', 'enfold_customization_header_widget_area' ); function enfold_customization_header_widget_area() { dynamic_sidebar( 'header' ); } // Display update time function wp_get_updated_date(){ $u_time = get_the_time('U'); $u_modified_time = get_the_modified_time('U'); if ($u_modified_time >= $u_time + 86400) { echo "<p class='update-time'>Updated at "; the_modified_time('F jS, Y'); echo " at "; the_modified_time(); echo "</p> "; } } add_shortcode( 'update_time', 'wp_get_updated_date' );
Then i added following code to bottom of Quick CSS in Enfold theme options > General Styling
p.update-time { width: 335px; margin: auto; }
Please review your website :)
Best regards,
YigitNovember 5, 2019 at 2:11 pm #1153997Yigit:
This is terrific. Looks great, Thank you.
KurtNovember 5, 2019 at 2:50 pm #1154002 -
AuthorPosts
- The topic ‘Add timestamp to Enfold page’ is closed to new replies.