rewrite rules not working the way expecting
-
Hi,
In a plugin I’m developing, I’m having a problem with getting rewrite rules to work.
For example, if I visit https://mysite/page-with-my-shortcode/ the page loads just fine and I see the data from my custom query, etc.
But as soon as I add onto the url paths like https://mysite/page-with-my-shortcode/genres/drama or https://mysite/page-with-my-shortcode/rating/pg and so forth, the page just redirects right back to https://mysite/page-with-my-shortcode/
add_filter('rewrite_rules_array', array(&$this, 'Plugin_Set_Rewrite_Rules')); add_filter('query_vars', array(&$this, 'Plugin_Set_Query_Vars')); add_filter('wp_loaded',array(&$this,'Plugin_FlushRules'));
function Plugin_Set_Rewrite_Rules($rules) { global $wp_rewrite; $fic_rules['page-with-my-shortcode/browse/?$'] = 'index.php?pagename=page-with-my-shortcode'; $fic_rules['page-with-my-shortcode/story/([^/]+)/?$'] = 'index.php?pagename=page-with-my-shortcode&story_title=$matches[1]'; $fic_rules['page-with-my-shortcode/story/([^/]+)/page-([0-9]+)/?$'] = 'index.php?pagename=page-with-my-shortcode&story_title=$matches[1]&page=$matches[2]'; $fic_rules['page-with-my-shortcode/genre/?$'] = 'index.php?pagename=page-with-my-shortcode'; $fic_rules['page-with-my-shortcode/rating/?$'] = 'index.php?pagename=page-with-my-shortcode'; $fic_rules['page-with-my-shortcode/story_category/?$'] = 'index.php?pagename=page-with-my-shortcode'; $fic_rules['page-with-my-shortcode/date/?$'] = 'index.php?pagename=page-with-my-shortcode'; $fic_rules['page-with-my-shortcode/genre/([^/]+)/?$'] = 'index.php?pagename=page-with-my-shortcode&genre=$matches[1]'; $fic_rules['page-with-my-shortcode/rating/([^/]+)/?$'] = 'index.php?pagename=page-with-my-shortcode&rating=$matches[1]'; $fic_rules['page-with-my-shortcode/story_category/([^/]+)/?$'] = 'index.php?pagename=page-with-my-shortcode&story_category=$matches[1]'; $fic_rules['page-with-my-shortcode/date/([^/]+)/?$'] = 'index.php?pagename=page-with-my-shortcode&date=$matches[1]'; $fic_rules['page-with-my-shortcode/genre/([^/]+)/page-([0-9]+)/?$'] = 'index.php?pagename=page-with-my-shortcode&genre=$matches[1]&page=$matches[2]'; $fic_rules['page-with-my-shortcode/rating/([^/]+)/page-([0-9]+)/?$'] = 'index.php?pagename=page-with-my-shortcode&rating=$matches[1]&page=$matches[2]'; $fic_rules['page-with-my-shortcode/story_category/([^/]+)/page-([0-9]+)/?$'] = 'index.php?pagename=page-with-my-shortcode&story_category=$matches[1]&page=$matches[2]'; $fic_rules['page-with-my-shortcode/date/([^/]+)/page-([0-9]+)/?$'] = 'index.php?pagename=page-with-my-shortcode&date=$matches[1]&page=$matches[2]'; $rules = array_merge($fic_rules, $rules); return $rules; } function Plugin_FlushRules() { global $wp_rewrite; $wp_rewrite->flush_rules(); } function Plugin_Set_Query_Vars($vars) { # forums and topics $vars[] = 'story_title'; $vars[] = 'genre'; $vars[] = 'rating'; $vars[] = 'story_category'; $vars[] = 'date'; return $vars; }
Hope this is enough info. What am I doing wrong?
- The topic ‘rewrite rules not working the way expecting’ is closed to new replies.