I am getting a 5XX error in Google Search Console after disabling the wordpress feeds. It worked correctly for about 6 months but it is no longer working correctly. I tried to look for solutions and I tried to see if maybe some of the code had been deprecated but I didn't see anything in search to highlight this. The code I added to disable the feed is listed below.
I tried to do a search in google and stack overflow but I did not find a solution to this problem. I did find the initial code in Google search but not a solution to the 5XX xml error message.
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);
First step: remove the feed links from the section of your site.
add_action('wp_head', 'wpse33072_wp_head', 1);
remove feed links from wp_head
function wpse33072_wp_head (){ remove_action('wp_head', 'feed_links', 2); remove_action('wp_head', 'feed_links_extra', 3);}
The expected results is a simple container that says "no feed available, please visit our homepage" when you visit the feed URL. When you view the source code, you should not be able to see the link to the feed in the header.
The actual results is that the header link to the feed is not there, it has been removed and this is correct, it is also the second part of the code presented above, I expected this but not the xml error that I am getting in the feed when I visit the feed URL. That is coming from the first part of the code I have presented. So the issue seems to be in the function "wpb_disable_feed".
My only other thought is that some other code may be conflicting with this one. I just haven't found it yet but I will, hopefully with a little help from the community.