實用的 WordPress ICP 備案許可管理器

WordPress 代碼段:禁用全站 Feed RSS 輸出

禁用 WordPress RSS 提要的第二種方法是簡單地使用代碼。

重要!如果操作不正確,編輯 WordPress 主題的源代碼可能會破壞你的網站。如果你不方便這樣做,請先諮詢開發人員。

將以下代碼複製到 WordPress 主題的 functions.php 文件中。

function itsme_disable_feed() {   wp_die( __( 'No feed available, please visit the <a href="'. esc_url( home_url( '/' ) ) .'">homepage</a>!' ) );  }    add_action('do_feed', 'itsme_disable_feed', 1);  add_action('do_feed_rdf', 'itsme_disable_feed', 1);  add_action('do_feed_rss', 'itsme_disable_feed', 1);  add_action('do_feed_rss2', 'itsme_disable_feed', 1);  add_action('do_feed_atom', 'itsme_disable_feed', 1);  add_action('do_feed_rss2_comments', 'itsme_disable_feed', 1);  add_action('do_feed_atom_comments', 'itsme_disable_feed', 1);    remove_action( 'wp_head', 'feed_links_extra', 3 );  remove_action( 'wp_head', 'feed_links', 2 );

 

你也可以選擇使用插件來禁用:

Disable Feeds

文章沒看懂?代碼不會用?需要幫助您可以

小新 的頭像