Mặc định WordPress có sẵn link feed rss nhưng trong một số trường hợp bạn muốn xoá bỏ nó. Vậy rất đơn giản, bạn chỉ cần thêm đoạn code sau vào file functions.php của theme bạn đang sử dụng là được nhé
/*
* Xoá bỏ link feed rss trong WordPress
* Author: levantoan.com
*/
function wp_disable_feeds() {
wp_safe_redirect(home_url(), 301);
die();
}
add_action('do_feed', 'wp_disable_feeds', 1);
add_action('do_feed_rdf', 'wp_disable_feeds', 1);
add_action('do_feed_rss', 'wp_disable_feeds', 1);
add_action('do_feed_rss2', 'wp_disable_feeds', 1);
add_action('do_feed_atom', 'wp_disable_feeds', 1);
add_action('do_feed_rss2_comments', 'wp_disable_feeds', 1);
add_action('do_feed_atom_comments', 'wp_disable_feeds', 1);
remove_action('wp_head', 'feed_links', 2 );
remove_action('wp_head', 'feed_links_extra', 3 );
Trong code trên giúp bạn 2 điều:
- Xoá bỏ link /feed trong <head>
- Chuyển hướng 301 toàn bộ link feed cũ về trang chủ
Từ khoá bạn có thể tìm kiếm:
- Cách xoá link feed trong WordPress
- Làm sao để xoá bỏ link feed RSS trong WordPress
- Disable feed rss in WordPress
- How to Disable WordPress RSS feed
- Bình luận