How To Show Relative Post Date For Your Blog Posts?
November 5th, 2016 | by Ravi Chahar || 4 Comments |
In most of the WordPress themes, you will notice that the published date will be showing below the post title or anywhere nearby.
There are many people who edit the theme files to show last updated date. But now another concept has come to the field.
There are a few websites which show relative post date. It means that you will see the time span which has crossed after publishing the post.
Like “2 hours ago, 18 hours ago” and similar to that. Would you like to show relative post date for all the blog posts of your blog?
Let Me Provide you The Guide To Show Relative Post Date.
As you know that the WordPress theme file structure consists many files and folders. And the output of your post is handled by the single.php file.
Though it may vary because nowadays, developers are using some similar files to control the output of the single posts.
Do you know how to edit the theme files? Well, you must learn that.
You will find any of the PHP code related to the dates. It may be different from your one theme to another.
<?php get_the_date(); ?><?php the_date(); ?>
<?php get_the_time(); ?>
If you want to change the date of the blog posts showing on the blogpage then you have to edit the index.php.
If you are having a custom home page then another file is there which should be edited. Search for front-page.php file in your theme folder.
Replace the code with a new code.
It would depend on your choice. If you only want to show relative post date for the single posts then edit the single.php file otherwise, search for all the files mentioned above.
How To Display relative post date Without Coding?
There are many people who are afraid of the codes. Well, there is a solution for them. They can use the plugin “WP-RelativeDate“.
Just install it and you will get a few options to configure. Set it according to our requirements. WordPress repository is full of plugins and you can find the solution for every problem.
This plugin can help you to accomplish the task of showing the post dates like you want.
Isn’t That So Easy To Configure And Show Relative Post Date?
There are a few themes which consist the relative date code inbuilt. But not every WordPress user wants that. So it’s better to do it yourself.
A good developer never adds something which isn’t relevant for all of the users. As you all know WordPress provides the freedom to its users to alter all the settings.
You can change the date display type. You can show the published date, last updated date, relative date. Add the code according to your choice. If you still have any doubt, feel free to clear it.