如何在WordPress中禁用RSS源

Do you want to disable RSS feeds on your WordPress site? RSS feeds allow users to subscribe to your blog posts. However when building small static websites, you may want to turn off the RSS feeds. By default, there is no option to remove RSS feeds in WordPress. In this article, we will show you how to disable RSS feeds in WordPress.

您要在WordPress网站上禁用RSS feed吗? RSS feed允许用户订阅您的博客文章。 但是,在构建小型静态网站时,您可能需要关闭RSS源。 默认情况下,没有选项可以删除WordPress中的RSS源。 在本文中,我们将向您展示如何在WordPress中禁用RSS feed。

Disable RSS Feeds in WordPress
方法1:使用插件禁用RSS提要 (Method 1: Disable RSS Feeds Using a Plugin)

This method is easier and is recommended for beginners.

此方法更简单,建议初学者使用。

First thing you need to do is install and activate the Disable Feeds plugin. For more details, see our step by step guide on how to install a WordPress plugin.

您需要做的第一件事是安装并激活“ 禁用提要”插件。 有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。

The plugin works out of the box and it will start redirecting users to your website when they request an RSS feed.

该插件开箱即用,当用户请求RSS feed时,它将开始将用户重定向到您的网站。

There are a few settings available for the plugin. You need to visit Settings » Reading page to configure them.

插件有一些可用设置。 您需要访问设置»阅读页面进行配置。

Disable Feeds plugin settings

By default, the plugin will try to redirect users to related content on your site when they request a feed. For example, users requesting a category feed will be redirected to category page. Users trying to access custom post type RSS feed will be redirected to the custom post type archive.

默认情况下,该插件会在用户请求供稿时尝试将用户重定向到您网站上的相关内容。 例如,请求类别供稿的用户将被重定向到类别页面。 尝试访问自定义帖子类型RSS feed的用户将被重定向到自定义帖子类型档案

You can change this behavior and show users a 404 error page.

您可以更改此行为,并向用户显示404错误页面。

You can also select not to disable the global RSS feed and comments feed. This will allow users to still subscribe to your RSS feed, but there will be no individual category, author, or post comment feeds.

您还可以选择不禁用全局RSS提要和评论提要。 这将使用户仍可以订阅您的RSS feed,但不会有单独的类别,作者或发布评论feed。

Don’t forget to click on the save changes button to store your settings.

不要忘记单击“保存更改”按钮来存储您的设置。

方法2:在WordPress中手动禁用RSS提要 (Method 2: Manually Disable RSS Feeds in WordPress)

This method requires you edit WordPress files. You can use this method if you are comfortable pasting snippets from web into WordPress.

此方法需要您编辑WordPress文件。 如果您愿意将Web片段粘贴到WordPress中,则可以使用此方法。

Simply add this code to your theme’s functions.php file or a site-specific plugin.

只需将此代码添加到主题的functions.php文件或特定站点的插件中即可


function wpb_disable_feed() {
wp_die( __('No feed available,please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!') );
}

add_action('do_feed', 'wpb_disable_feed', 1);
add_action('do_feed_rdf', 'wpb_disable_feed', 1);
add_action('do_feed_rss', 'wpb_disable_feed', 1);
add_action('do_feed_rss2', 'wpb_disable_feed', 1);
add_action('do_feed_atom', 'wpb_disable_feed', 1);
add_action('do_feed_rss2_comments', 'wpb_disable_feed', 1);
add_action('do_feed_atom_comments', 'wpb_disable_feed', 1);

This code simply returns an error page when someone requests an RSS feed.

当有人请求RSS feed时,此代码仅返回错误页面。

Feeds disabled error page in WordPress

We hope this article helped you learn how to disable RSS feeds in WordPress. You may also want to see our list of 15 most annoying things about WordPress and how to fix them.

我们希望本文能帮助您学习如何在WordPress中禁用RSS feed。 您可能还想查看我们有关WordPress15个最烦人的事情以及如何修复它们的列表

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-disable-rss-feeds-in-wordpress/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值