波卡 發表於 2016-1-5 16:00:35

停用 WordPress RSS Feeds 功能

方法一:(停用 WordPress RSS Feeds 功能)

[*]編輯佈景主題的 functions.php 檔案,路徑 /wp-content/themes/使用的佈景主題/functions.php。
[*]在最後一行加入以下程式碼。

/** 停用 WordPress RSS Feeds 功能 **/
function wp_disable_feed() {
wp_die( '目前不提供 RSS 功能,請前往我們的 <a href="'. get_bloginfo('url') .'" rel="nofollow" >首頁</a>。' );
}
add_action('do_feed', 'wp_disable_feed', 1);
add_action('do_feed_rdf', 'wp_disable_feed', 1);
add_action('do_feed_rss', 'wp_disable_feed', 1);
add_action('do_feed_rss2', 'wp_disable_feed', 1);
add_action('do_feed_atom', 'wp_disable_feed', 1);

方法二:(停用 WordPress RSS Feeds 功能,並且移除 <head> 標籤裡的 RSS 資訊)

[*]編輯佈景主題的 functions.php 檔案,路徑 /wp-content/themes/使用的佈景主題/functions.php。
[*]在最後一行加入以下程式碼。

/** 停用 WordPress RSS Feeds 功能 **/
function wp_disable_feed() {
wp_die( '目前不提供 RSS 功能,請前往我們的 <a href="'. get_bloginfo('url') .'" rel="nofollow" >首頁</a>。' );
}
add_action('do_feed', 'wp_disable_feed', 1);
add_action('do_feed_rdf', 'wp_disable_feed', 1);
add_action('do_feed_rss', 'wp_disable_feed', 1);
add_action('do_feed_rss2', 'wp_disable_feed', 1);
add_action('do_feed_atom', 'wp_disable_feed', 1);
remove_action('wp_head', 'feed_links_extra', 3);
remove_action('wp_head', 'feed_links', 2);

static/image/hrline/line5.pnghttp://bbs.skyey.tw/static/image/hrline/line5.pnghttp://bbs.skyey.tw/static/image/hrline/line5.pnghttp://bbs.skyey.tw/static/image/hrline/line5.pnghttp://bbs.skyey.tw/static/image/hrline/line5.pnghttp://bbs.skyey.tw/static/image/hrline/line5.pnghttp://bbs.skyey.tw/static/image/hrline/line5.pnghttp://bbs.skyey.tw/static/image/hrline/line5.pnghttp://bbs.skyey.tw/static/image/hrline/line5.png
☆完成之後就將WordPress RSS Feeds 功能關閉了,前往/feed/頁面,就會出現錯誤訊息。
固定網址:http://您的網址/feed
預設網址:
http://您的網址/?feed=rss2

追加:(將瀏覽 RSS 的訪客自動轉至首頁)
[*]編輯 .htaccess 檔案。
[*]加入以下代碼,將 http://您的網址/ 改為您的網址。
#停用 WordPress RSS Feeds 功能
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule feed(.*) http://您的網址/
</ifModule>


頁: [1]
查看完整版本: 停用 WordPress RSS Feeds 功能