Update: Upgrade breaks API path
-
This is an update on the topic of the /api/ path breaking and 404ing sometimes, which we discussed here: http://wordpress.org/support/topic/upgrade-breaks-api-path, but since that topic is closed for new replies, and I have new information to share, I’m starting a new post.
After hitting the 404 a few more times, I finally diagnosed it on my end. Please take a look and advise on a fix if possible.
The /api/ starts 404ing when I add a new custom feed, flush rewrite rules so that this feed is registered, and then uncomment the flush command, as per best practices (http://codex.wordpress.org/Function_Reference/flush_rewrite_rules).
Here’s the code in my functions.php:
function my_rewrite_rules( $wp_rewrite ) { $new_rules = array( 'feed(?:/|\?|$)(.+)' => 'index.php?feed='.$wp_rewrite->preg_index(1) ); $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } function my_add_custom_feeds() { global $wp_rewrite; add_feed('blabla_feed', 'my_full_feed'); /***** RE-ENABLE THESE LINES IF YOU ADD A NEW FEED, BUT KEEP DISABLED OTHERWISE *****/ // add_action('generate_rewrite_rules', 'my_rewrite_rules'); // $wp_rewrite->flush_rules(); } add_action('init', 'my_add_custom_feeds');When I add a new feed, I add a new add_feed call, uncomment add_action and flush_rules, hit the site, then comment them back. As soon as I comment them back, the JSON API /api/ path becomes a 404.
Thoughts on fixing this?
The topic ‘Update: Upgrade breaks API path’ is closed to new replies.