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
3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Briant
Briant
2 years ago

I can't seem to make this work

Briant
Briant
2 years 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' )));

?>

Brooks
Brooks
1 year ago
Reply to  Briant

minor correction with yours. the ' should come after ago not after %s so something like this

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

Last edited 1 year ago by James LePage
Article By
James LePage
Contributors/Editors
notloggedin
James LePage is the founder of Isotropic, a WordPress education company and digital agency. He is also the founder of CodeWP.ai, a venture backed startup bringing AI to WordPress creators.
We're looking for new authors. Explore Isotropic Jobs.
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram