Home>Article>CMS Tutorial> How to display relative dates in WordPress

How to display relative dates in WordPress

藏色散人
藏色散人 forward
2019-12-06 13:44:51 3104browse

The following columnWordPress Tutorialwill introduce to you how to display relative dates in WordPress. I hope it will be helpful to friends in need!

How to display relative dates in WordPress

Relative date, the article or comment publication date is displayed in the form of "published 1 hour ago", this form of display, the relative date will give people a sense that the content entry was published from now It feels very close, so many news websites and social media websites like to use this relative date.

If your WordPress website also wants to display the article publication time in a relative date, you can refer to this article.

1. Automatically display relative time

You need to install and activate the Meks Time Ago plug-in. After enabling the plug-in, enter the WP background→Settings, and scroll to the following "Meks Time Ago Options" on the general options page. "After making relevant settings, save.

How to display relative dates in WordPress

Open the recently published article on your website again, and you will find that the article publication date and comment date have become relative dates.

2. Manually modify the relative time

First you need to install and activate the WP RelativeDate plug-in.

Then find the current theme single.php, content-single.php, comments.php template file and replace it like:

  

with:

The above is the detailed content of How to display relative dates in WordPress. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:zmingcx.com. If there is any infringement, please contact admin@php.cn delete