I need a way to add in the footer the last update date for a page or a post. I would prefer to modify Global CSS and Javascript if at all possible. Modifying a child theme PHP is possible but not desirable. I’ve looked through a variety of support topics but I’m not finding the right solution. Any help is appreciated
Hello @brinkleyr,
Thanks for asking.
You can take a look at following plugins to display last updated information.
Thanks.
What about something that combines the solution for adding a year to a copyright notice (suggested in https://theme.co/apex/forums/topic/add-current-year-to-footer/#post-226892):
==================
Thanks for writing in! You can use the following code in your footer content:
Copyright TEXT Company Name - All Rights Reserved.
And then, add the following code into your Customizer, Custom > JavaScript section.jQuery(document).ready(function() {
var currentYear = (new Date).getFullYear();
jQuery("#year").text( (new Date).getFullYear() );
});
==================
With the Last Updated: solution in https://theme.co/apex/forums/topic/add-last-updated-to-footer/ (see below)
If there were some way to do this with Custom Global Javascript and Custom CSS?
I might prefer that over yet another plugin. But maybe the plugin is the right solution.
Thoughts?
==================
You can add this in your child theme’s functions.php
function site_last_updated($d = ‘’) {
$recent = new WP_Query(“showposts=1&orderby=modified&post_status=publish&post_type=any”);
if ( $recent->have_posts() ) {
while ( $recent->have_posts() ) {
$recent->the_post();
$last_update = get_the_modified_date($d);
}
echo $last_update;
}
else
echo ‘No posts.’;
}
Then create file wp-footer.php in wp-content/themes/x-child/framework/views/ethos and copy the code below into that file
<footer class="x-colophon bottom" role="contentinfo">
<div class="x-container max width">
<?php if ( x_get_option( 'x_footer_content_display', '1' ) == '1' ) : ?>
<div class="x-colophon-content">
<?php echo x_get_option( 'x_footer_content' ); ?>
</div>
<?php endif; ?>
<div class="last-updated"><?php echo site_last_updated('') ?></div>
<?php if ( x_get_option( 'x_footer_menu_display', '1' ) == '1' ) : ?>
<?php x_get_view( 'global', '_nav', 'footer' ); ?>
<?php endif; ?>
<?php if ( x_get_option( 'x_footer_social_display', '1' ) == '1' ) : ?>
<?php x_social_global(); ?>
<?php endif; ?>
</div>
</footer>
<?php endif; ?>
<?php x_get_view( 'global', '_footer' ); ?>
After that add the code below in custom > css box in the customizer.
.x-colophon.bottom .last-updated {
display:block;
clear:both;
float:none;
overflow:hidden;
text-align:center;
}
Ignore the above…I went with Last Modified Timestamp plugin…Works great and is up to date compared to the others. You can find it here.
Glad you’ve found a solution.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.