Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #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,
    Kfranck

    #1153720

    Hi,

    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,
    Yigit

    #1153725

    Yigit:

    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,
    Kfranck

    #1153746

    I 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,
    kfranck

    #1153945

    Hi,

    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,
    Yigit

    #1153997

    Yigit:
    This is terrific. Looks great, Thank you.
    Kurt

    #1154002

    Hi,

    You are welcome, Kurt. Let us know if you have any other questions or issues :)

    Best regards,
    Yigit

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Add timestamp to Enfold page’ is closed to new replies.