As many will note, inside Carbonate the default display under a single post is the date of the post being updated, this dated aspect can make it easy to tell how aged a post is by any visitor which could lead to a bounce if it appears aged.
Instead I have swapped this date using a custom function to show the relative time since last update which will hopefully be a year or less if you are properly attacking yearly content audits and cleaning up frequently.
So where the theme before showed ” Last Updated: July 2020 ” it now would say ” Last Updated: 6 Months Ago ” this obfuscates the timeline to people as they don’t see this the same way.
So how do we go about making this change to the theme? Well it is actually quite simple as you will only need to add a section of code to the functions.php and then update the single line of code in your single.php file.
First lets grab the function needed to convert the time over to a relative time:
function relative_modified_time() {
$last_modified_time = get_the_modified_time('U');
$current_time = current_time('U');
return human_time_diff($last_modified_time,$current_time) . " ago";
}
Copy the above and you want to add into your functions.php file just before the end of the file which looks like the below, normally the very last line in the editor:
?>
This code basically uses the built in WordPress functionality to convert time from 2 timestamps and return the difference in a human timescale instead of a fixed date. Read More on human_time_diff
Make sure to save the file after this change
So now that this will return a human time you need to actually implement it within your template for posts to display this new function instead of the previous function.
Now you will want to change the single.php to add this new function in place of the old, I have described this process below to show you what it looks like by default and what you want it to look like after.
From the basic theme setup you have php showing the_date() function, instead you will remove that part and replace it with the new function you built above relative_modified_time().
<strong>Last Updated:</strong> <?php the_date(); ?>
After this change your line should look like the below:
<strong>Last Updated: </strong> <?php echo relative_modified_time(); ?>
Make sure to save the file after this change
Now you would want to flush any cache you have, whether local, server, CDN, or inside Ezoic or similar services to load this new code for users who aren’t signed in.
If you find this helpful please feel free to donate spare change (if you can) over here.
In this short tutorial we go through the steps to add a previous and next post option onto your homepage to allow moving to older or newer posts.
Yoast has lately had numerous issues lately with de-ranking content because of changes they made within their plugin, RankMath is new and exciting for SEO.
The Acabado theme was created by Income School and is a quick to setup theme which drives you directly to creating blog posts and content with minimal work!
In this tutorial we will go about adding a fully functional sidebar to Carbonate that includes enabling a Widget area for adding plugins.
When you use Carbonate you have a very basic streamlined theme built for providing access to a few categories but no tags, today I changed that for PBI!