wordpress显示摘要_如何延迟帖子在WordPress RSS Feed中的显示

wordpress显示摘要

Recently, one of our readers asked if it’s possible to delay posts from appearing in the WordPress RSS feed? Delaying posts in your RSS feed can save you from accidental publishing and beat content scrapers in SEO. In this article, we will show you how to delay post from appearing in WordPress RSS feed.

最近,我们的一位读者问是否有可能延迟帖子在WordPress RSS feed中的显示? 延迟RSS feed中的帖子可以使您免于意外发布并避免在SEO中刮擦内容。 在本文中,我们将向您展示如何延迟帖子在WordPress RSS feed中的显示。

How to Delay Posts From Appearing in WordPress RSS Feed
为什么延迟馈送WordPress? (Why Delay Feed in WordPress?)

Sometimes you may end up with a grammar or spelling mistake in your article. The mistake goes live and is distributed to your RSS feed subscribers. If you have email subscriptions on your WordPress blog, then those subscribers will get it as well.

有时,您可能会在文章中出现语法或拼写错误 。 该错误会继续存在,并分发给您的RSS feed订阅者。 如果您在WordPress博客电子邮件订阅 ,那么这些订阅者也将获得它。

Spelling mistakes go live to your RSS feed subscribers

By adding a delay between your RSS feed and your live site, you get a little time window to catch an error on a live site and fix it.

通过在RSS feed和实时站点之间添加延迟,您将获得一个小的时间窗口来捕获实时站点上的错误并进行修复。

RSS feeds are also used by content scraping websites. They use it to monitor your content and copy your posts as soon as they appear live.

内容抓取网站也使用RSS feed。 他们使用它来监视您的内容,并在它们出现在实时状态时立即复制您的帖子。

If you have a new website with little authority, then a lot of times these content scrapers may end up beating you in the search results.

如果您拥有一个权限不大的新网站,那么这些内容抓取工具在很多情况下最终可能会在搜索结果中击败您。

Content scrapers use RSS feeds to auto-publish your posts

By delaying an article in the feed, you can give search engines enough time to crawl and index your content first.

通过延迟提要中的文章,您可以给搜索引擎足够的时间来首先对内容进行爬网和索引。

Having said that, let’s see how to easily delay posts from appearing in WordPress RSS feed.

话虽如此,让我们看看如何轻松地延迟帖子在WordPress RSS feed中的显示。

延迟WordPress RSS Feed中的帖子 (Delaying Posts in WordPress RSS Feed)

This method requires you to add little code into WordPress. If this is your first time adding code manually, then take a look at our beginner’s guide on pasting snippets from web into WordPress.

此方法要求您向WordPress添加少量代码。 如果这是您第一次手动添加代码,请查看有关将网页摘要粘贴到WordPress的初学者指南

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

您需要将以下代码添加到主题的functions.php文件或特定站点的插件中


function publish_later_on_feed($where) {

	global $wpdb;

	if ( is_feed() ) {
		// timestamp in WP-format
		$now = gmdate('Y-m-d H:i:s');

		// value for wait; + device
		$wait = '10'; // integer

		// http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
		$device = 'MINUTE'; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR

		// add SQL-sytax to default $where
		$where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait ";
	}
	return $where;
}

add_filter('posts_where', 'publish_later_on_feed');

This code checks to see if a WordPress feed is requested. After that it sets the current time and the time you want to add as delay between post’s original date and the current time.

此代码检查是否请求了WordPress feed。 之后,它将设置当前时间和您要添加的时间,以作为发布原始日期和当前时间之间的延迟。

After that it adds the timestamp difference as the WHERE clause to the original query. The original query will now only return the posts where timestamp difference is greater than the wait time.

之后,它将时间戳差异作为WHERE子句添加到原始查询。 现在,原始查询将仅返回时间戳差异大于等待时间的帖子。

In this code we have used 10 minutes as $wait or delay time. Feel free to change that into any number of minutes you want. For example, 60 for 1 hour or 120 for two hours.

在此代码中,我们将10分钟用作$ wait或延迟时间。 随意将其更改为所需的任何分钟数。 例如,60表示1小时或120表示两个小时。

We hope this article helped you learn how to easily delay posts from appearing in WordPress RSS feed. You may also want to see our guide on how to show content only to RSS subscribers in WordPress.

我们希望本文能帮助您学习如何轻松地延迟帖子在WordPress RSS feed中的显示。 您可能还想查看我们的指南,该指南介绍如何在WordPress中向RSS订阅者显示内容

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-tutorials/how-to-delay-posts-from-appearing-in-wordpress-rss-feed/

wordpress显示摘要

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值