isotropic-2022
Share
Blog
Search
Menu

Published X Minutes/Days Ago On Oxygen Builder

By James LePage
 on October 24, 2020
Last modified on January 7th, 2022

Published X Minutes/Days Ago On Oxygen Builder

By James LePage
 on October 24, 2020
Last modified on January 7th, 2022

If you're looking for an easy way to display a “this article was published 6 minutes ago” on your WordPress website built with Oxygen Builder, this article is for you.

This guide is specifically created for the Oxygen Builder repeater element, but it can definitely be expanded to easy posts, and even a non-Oxygen WordPress website.

First, insert your date into the repeater element by using the dynamic data aspect of the builder. Don't add any additional things to this date, keep it in its default format.

The only additional step that you need to take is inserting a code block, and pasting in this PHP.

The changes will not display in the builder, but on the front end of your Oxygen Builder website, the post date will show as “published 28 minutes ago”, or something like that.

Keep in mind; you can display “published x time ago” by using this method on any WordPress website, not specifically Oxygen. To do that, you would probably need to install a plugin called code snippets, and paste that PHP in there. Then, you may need to edit your theme files, make a child theme, or do some other back end alterations.

<?php function iso_post_time_ago () { return sprintf( esc_html__( '%s ago', 'textdomain' ), human_time_diff(get_the_time ( 'U' ), current_time( 'timestamp' ) ) ); } add_filter( 'get_the_date', 'iso_post_time_ago' );?>
Code language: HTML, XML (xml)

Subscribe & Share
If you liked this content, subscribe for our monthly roundup of WordPress news, website inspiration, exclusive deals and interesting articles.
Unsubscribe at any time. We do not spam and will never sell or share your email.
Subscribe
Notify of
guest
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Briant
Briant
5 months ago

I can't seem to make this work

Briant
Briant
5 months ago
Reply to  Briant

the code was breaking my page with the repeater element. So I used this inside a code block and it worked flawlessly:

<?php

echo sprintf( esc_html__( '%s' ago, 'textdomain' ), human_time_diff(get_the_time ( 'U' ), current_time( 'timestamp' )));

?>

Article By
James LePage
Contributors/Editors
notloggedin
James LePage is the founder of Isotropic Design, a digital agency that builds WordPress websites. I read, write and design constantly!
We're looking for new authors. Explore Isotropic Jobs.
Close
🇺🇸 English
Save posts, access exclusive content, join members-only communities and more.
Dark Mode Toggle
Love web dev? Join the Isotropic weekly newsletter.
cross
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
0

Your Cart is Empty