How to display last updated date on WordPress Bam theme

How to display last updated date on WordPress Bam theme

WordPress Bam by ThemezHut is a fantastic theme that we use at GeekyHacker. Yet, it has some shortcomings. One of which is the lack of flexible configuration to display the last updated date on posts and pages instead of the published date. But no worries, with some small tweaks it’s possible to enable that as the functionality and code already exist. In this post, we explain exactly how to display the last updated date on the WordPress Bam theme.

Editing WordPress Bam theme

The first thing you need to know is how to edit the Bam theme and where it is located. Navigate to the admin panel, and from there go to “Appearance -> Theme File Editor“. Then, from the right side menu, select the “inc -> template-tag.php” file. That’s the place where we need to apply most of the changes.

WordPress Theme File Editor

Available options

There are two possibilities to add the last updated date on the Bam theme. One is to have it in addition to the published date. Another is to substitute the published date with the last updated date. Let’s look at each of them closely.

Add last updated date in addition to published date

With this approach, you can keep the published date and add the last updated date next to it. For that, first, open the template-tags.php file. Under the bam_posted_on function, you should see the below code:

Now what you need to do is to change line 4 of the above code to this:

We have modified the CSS class from updated to entry-date published because the former is marked as hidden under style-rtl.css, style.css, and sass/site/primary/_posts-and-pages.scss files.

Of course, if you are familiar with CSS, you can modify those files according to your needs and avoid binding the published date CSS to the updated date. However, what is explained already is the easiest approach.

Display last updated date instead of published date on WordPress Bam theme

In this approach, we replace the published date with the last updated date. It’s my preferred way since the content won’t be cluttered with unnecessary information. In addition to that, theme maintenance is simpler. To apply the changes, you need to open the template-tags.php file and modify the code from this:

To this,

We have made three important changes. First, we modified the $time_string variable and added the custom Last updated on message. The second change was to remove the if condition as it’s no longer needed. And lastly, we changed sprintf parameters to call get_the_modified_date (last updated date) instead of get_the_date (published date).

The end result would look like this:

Last update date

Final notes

In this article, we covered how to display last updated date on WordPress Bam theme in two different ways. One way is to add the last updated date next to the published date. The other is to replace the published date with the last updated date.

However, the most important thing regardless of the approach you adopt that you need to remember is if you update the theme, all the changes would be overwritten (will be gone). So you need to re-apply them. It’s good to keep track of theme changes in a separate place and have backups for emergency cases. If you are technical, or even up for a challenge, you can use GitHub to keep track of all your theme changes. You can start learning git following our awesome tutorials. Otherwise, having a copy of your changes on your computer, or any other preferred method would be good enough.

Inline/featured images credits

  • Featured image by Markus Winkler from Pexels