WordPress Rewrire rule is not working
-
I am trying to create a rewrite rule for one of my custom page and here is the rewrite rule
function add_my_rule() { global $wp; $wp->add_query_var('name_state'); $wp->add_query_var('arg_second'); add_rewrite_rule('state/([^/]+)/([^/]+)/page/([^/]+)','index.php?pagename=places-to-visit&name_state=$matches[1]&arg_second=$matches[2]&paged=$matches[3]','top'); add_rewrite_rule('state/([^/]+)/([^/]+)','index.php?pagename=places-to-visit&name_state=$matches[1]&arg_second=$matches[2]','top'); global $wp_rewrite; $wp_rewrite->flush_rules(); } add_action('init', 'add_my_rule');
Here is what i am trying to do.
I have following URLwww.mydomain.com/state/state-name/places-to-visit
I have already created a custom page with name
places-to-visit.php
.My intentions are to redirect all such URL’s to this custom page and want following information as query variable from the URL[ Moderator note: Fixed. Please wrap
<li>
with<ol>
or<ul>
. ]- state-name
- places-to-visit
I have already tried to flush/update permalink from WordPress dashboard but nothing is working as per my expectation.
Can any one point me as where i am doing wrong?
- The topic ‘WordPress Rewrire rule is not working’ is closed to new replies.