1

I want to disable rss feed,my wordpress version is 5.2.4.

see my code below to disable rss feed.

 function itsme_disable_feed() {
 wp_die( __( 'No feed available' ) );
}

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);

By the book,the feed page will show wp_die page.But it didn`t show it Expectantly.

It shows this,see the screenshot,and I don`t know how to solve it.

enter image description here

  • Have you flushed rewrite rules and cleared any layers of caching? – WebElaine Dec 2 at 19:53
  • yeah,I have flushed the permalink and cleared the browser cach – Cindy Lu Dec 2 at 19:58
  • @Cindy Lu Hope this referrence helpful for you wpcaptain.com/blog/… – Gopalakrishnan18 Dec 3 at 10:16
1

have you tried using remove_action?

Example:

<?php
add_action('wp_head', 'remove_feeds_in_head', 1);

function remove_feeds_in_head() {
    remove_action( 'wp_head', 'feed_links', 2 );
    remove_action( 'wp_head', 'feed_links_extra', 3 );
}

EDIT: So disabling them doesn't remove them, to completely get rid of them, them you need to use remove_action aswell. Assuming this is what you want to do.

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', 2 );
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action('wp_head', 'rsd_link');
// Add whatever other things you want to remove
  • yeah,but your function just remove the feed link from source code. – Cindy Lu Dec 3 at 2:12
  • @CindyLu I just updated my answer to give a little more clarity. – Eoin H Dec 3 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.