Advanced Permalinks Plugin RSS Feed Fix


I use the Advanced Permalinks plugin on my site because I changed my permalink structure and didn’t want incoming links to return 404 errors. However, at some point the plugin has broken the RSS feed functionality of WordPress. When I visit the feed url on my site, a blank page is returned with no errors.

It appears that this is due to the Advanced Permalinks plugin ending the php script if the redirect parameter is present, even if the plugin didn’t preform any redirect.

Here is a patch file to fix the problem (For Advanced Permalinks 0.1.21)

--- advanced-permalinks-0.1.21/advanced-permalinks.php	2012-05-05 09:06:10.000000000 -0600
+++ advanced-permalinks/advanced-permalinks.php	2012-08-31 14:13:06.006393800 -0600
@@ -451,13 +451,18 @@
 		// Have we triggered a redirect?
 		if (isset ($vars->query_vars['redirect']))
 		{
-			if (isset ($vars->query_vars['author_name']))
+            $didRedirect = false;
+			if (isset ($vars->query_vars['author_name'])){
 				wp_redirect (get_author_posts_url (0, $vars->query_vars['author_name']));
-			else if (isset ($vars->query_vars['category_name']))
+                $didRedirect = true;
+            }
+			else if (isset ($vars->query_vars['category_name'])){
 				wp_redirect (get_category_link (get_category_by_path ($vars->query_vars['category_name'])));
+                $didRedirect = true;
+            }
 
-			// Stop anything else
-			die ();
+            if($didRedirect)
+                die();
 		}
 
 		// Workaround for WP 2.3

Save the text to a file and run patch against your Advanced Permalinks directory.

Or, if you want to manually modify the plugin, open up the advanced-permalinks.php file in the editor, and change the contents of the parse_request function to be:

/**
 * Hook into the 'parse_request' action and check if our rewrite rules require a redirection
 *
 * @param array $vars Variables
 * @return array Variables
 **/
 
function parse_request ($vars)
{
	// Have we triggered a redirect?
	if (isset ($vars->query_vars['redirect']))
	{
		$didRedirect = false;
		if (isset ($vars->query_vars['author_name'])){
			wp_redirect (get_author_posts_url (0, $vars->query_vars['author_name']));
			$didRedirect = true;
		}
		else if (isset ($vars->query_vars['category_name'])){
			wp_redirect (get_category_link (get_category_by_path ($vars->query_vars['category_name'])));
			$didRedirect = true;
		}
 
		if($didRedirect)
			die();
	}
 
	// Workaround for WP 2.3
	global $wp_db_version;
	if ($wp_db_version > 6000 && isset ($vars->query_vars['category_name']))
	{
		$vars->query_vars['category_name'] = str_replace ('.html', '', $vars->query_vars['category_name']);
		$vars->matched_query               = str_replace ('.html', '', $vars->matched_query);
	}
 
	return $vars;
}
  1. #1 by Sk on October 10, 2012 - 10:56 am

    Thanks a lot! It solved the problem.

  2. #2 by Leeanna on January 15, 2013 - 12:52 pm

    I am SO happy I managed to find this, and that you came up with this fix! I was almost ready to reinstall my whole site and start over, because I couldn’t figure out why my feed broke.

    Thank you, thank you, thank you!

  3. #3 by Felix on February 12, 2013 - 8:30 am

    Ahh…this was so useful. I was trying to find a solution for my feed problem but couldn’t find anything.

    Worked perfectly by using the manual method.

  4. #4 by aloata on March 9, 2013 - 5:00 am

    very useful! Worked in wordpress 3.5.1
    good job!
    thanks 😀

  5. #5 by gt on January 19, 2014 - 1:36 pm

    Wanted to say thanks very much – was at a loss as to why my feeds were blank – found a post elsewhere suggesting this plugin was to blame and came across your post – a quick fix … thanks!

  6. #6 by DoZ on May 13, 2014 - 1:40 am

    Many thanks to this fix! :)

  7. #7 by Jamie on August 17, 2015 - 10:44 am

    Worked for me. Thank you!

(will not be published)