So I have seen on other sites using Newspaper that you can change the date under the title of a post to say “3 days ago” rather than “January 26, 2017”, but I can not seem to find the setting for it (I did find a setting in wordpress where you can change it to just use numbers, like “26-1-2017” or other formats). That is of course assuming there is one, and that they have not used other means to make it look like it does.
Maybe I have not been thorough enough with my search, but hopefully someone knows what to do 🙂
Hello Digitally,
Please keep in mind that you want to change the structure of the date for modules, you will have to edit the corresponding files according to your block used by you. For example, if you are using the Block 3 you will have to edit the modules which make up this block, like module 1, like this -> http://screencast.com/t/whTutD5OFRyy
You will have to use the following snippet of code, like this ->
<?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?> in the core file, like this -> http://screencast.com/t/ZZYWvi253eL1 Clear all your cache and check the results.
Hope this helps!
Thanks for the message!
I’m trying to add this feature to the Big Grid on the homepage. This means I need to do
<?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>
where get_the_time('U') needs to be replaced with the post DateTime for each post. Right now this string comes from
<?php echo $this->get_date();?>
But this returns <span class="td-post-date"><time class="entry-date updated td-module-date" datetime="2016-03-01T00:04:01+00:00" >March 1, 2016</time></span> instead of just a date.
Is there a straightforward way to grab the date from $this->get_date(); so it can be used inside the <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?> function?
What other data can I get from $this? Could I get the Post ID?
I see
$this->get_title();
$this->get_author();
$this->get_date();
$this->get_category();
$this->get_image
are used in the theme.
Update, I solved it like this
<?php $post_id = $this->post->ID;?>
<?php echo human_time_diff( get_the_time('U', $post_id), current_time('timestamp') ) . ' ago'; ?>
