删除wordpress_如何从WordPress注释中删除日期和时间

删除wordpress

Do you want to remove dates from the WordPress comments area on your website? Recently bloggers have been wanting to remove comment dates to make their comments look fresh and evergreen. In this article, we will show you how to remove dates from WordPress comments.

您是否要从网站上的WordPress评论区域中删除日期? 最近,博客作者一直希望删除评论日期,以使他们的评论看起来新鲜和常绿。 在本文中,我们将向您展示如何从WordPress注释中删除日期。

Removing date and time from WordPress comments
您应该从WordPress评论中删除日期吗? (Should you Remove Date from WordPress Comments?)

Some users believe that hiding date and time in WordPress will prevent their articles from looking dated thus improving their improve WordPress SEO and search engine rankings.

一些用户认为, 在WordPress中隐藏日期和时间将阻止其文章过时,从而改善了他们的WordPress SEO和搜索引擎排名。

We disagree with this sentiment. In fact, we believe removing dates can be quite problematic.

我们不同意这种观点。 实际上,我们认为删除日期可能会有很大问题。

You can see our article on why you should not remove dates from WordPress posts for more details.

您可以查看有关为何不应该从WordPress帖子中删除日期的文章,以了解更多详细信息。

Same arguments are true for your WordPress comments as well. Removing date and time from comments will hide important information which would make older comments look odd.

同样的论点也适用于您的WordPress注释。 从评论中删除日期和时间将隐藏重要信息,这会使较旧的评论看起来很奇怪。

However, we understand that some users may be using comments differently than normal web comments. For example, on a WordPress intranet or a web application.

但是,我们了解到某些用户使用的评论可能与普通的网络评论不同。 例如,在WordPress内部网上或Web应用程序上。

In that case, they may need to remove date or time from WordPress comments to meet their requirements.

在这种情况下,他们可能需要从WordPress注释中删除日期或时间以满足他们的要求。

That being said, let’s take a look at how to easily remove date and time from WordPress comments.

话虽如此,让我们看一下如何轻松地从WordPress评论中删除日期和时间。

从WordPress注释中删除日期和时间 (Removing Date and Time from WordPress Comments)

This tutorial requires you to edit your WordPress theme files. If you haven’t done this before, then please take a look at our guide on how to copy and paste code in WordPress.

本教程要求您编辑WordPress主题文件。 如果您以前没有做过,请查看我们的指南,了解如何在WordPress中复制和粘贴代码

First you need to add the following code in your theme’s functions.php file or in a site-specific plugin.

首先,您需要在主题的functions.php文件或特定站点的插件中添加以下代码。


// Remove comment date
function wpb_remove_comment_date($date, $d, $comment) { 
	if ( !is_admin() ) {
    	return;
	} else { 
		return $date;
	}
}
add_filter( 'get_comment_date', 'wpb_remove_comment_date', 10, 3);

// Remove comment time
function wpb_remove_comment_time($date, $d, $comment) { 
	if ( !is_admin() ) {
    		return;
	} else { 
			return $date;
	}
}
add_filter( 'get_comment_time', 'wpb_remove_comment_time', 10, 3);


You can now visit any post with comments on your website, and you will see the date and time are no longer visible.

现在,您可以访问网站上带有评论的任何帖子,并且您将看到日期和时间不再可见。

Date and time removed from comments

However, you may also find preposition words like ‘at’ or ‘posted on’ left behind.

但是,您可能还会发现诸如“ at”“ posted on”之介词。

To remove them, you need to point the cursor to those words and right-click to select ‘Inspect’ from the browser menu.

要删除它们,您需要将光标指向这些单词,然后右键单击以从浏览器菜单中选择“检查”。

CSS class surrounding date and time in comments

Next, you need to note the CSS class used in the surrounding div or span around date/time in your theme.

接下来,你需要注意周围使用CSS类divspan在你的主题围绕的日期/时间。

After that you need to add the following custom CSS to your theme to hide this information:

之后,您需要将以下自定义CSS添加到主题中以隐藏此信息:


.comment-time { 
display:none; 
}

You can now save your changes and visit your website to see it in action.

现在,您可以保存所做的更改并访问您的网站以查看实际操作。

No date / time with WordPress comments

That’s all you have successfully removed date and time from WordPress comments.

这就是您成功从WordPress评论中删除日期和时间的全部。

Please note that this method does not remove comment dates and time from your WordPress database. Removing the code will immediately start displaying date and time for WordPress comments on your site.

请注意,此方法不会从WordPress数据库中删除评论日期和时间。 删除代码将立即开始在您的站点上显示WordPress注释的日期和时间。

We hope this article helped you learn how to easily remove date and time from WordPress comments. You may also want to see our list of the must have WordPress plugins for business websites.

我们希望本文能帮助您学习如何轻松地从WordPress评论中删除日期和时间。 您可能还想查看我们的必须具有用于商务网站的WordPress插件的列表。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/wp-themes/how-to-remove-date-and-time-from-wordpress-comments/

删除wordpress

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值