I'm trying to use add_rewrite_rule to make custom URL. My problem is the same as here : Custom Rewrite with Query vars
But I tried the 2 solutions, and it doesn't work for me.
For testing, I installed locally a new version of wordpress with default theme Twenty fifteen. I installed the plugin Rewrite rules Inspector to see all the active rules. I added a page "test" and added this function in function.php :
add_filter( 'query_vars', 'query_vars' );
function query_vars( $vars )
{
array_push($vars, 'information');
return $vars;
}
add_action( 'rewrite_rules_array', 'rewrite_rules' );
function rewrite_rules( $rules )
{
$newrules = array();
$newrules[ 'test/information/people/?$' ] = 'index.php?pagename=test&information=people';
return $newrules + $rules;
}
I don't forget to flush the new rules.
But when I go to : index.php?pagename=test&information=people
wordpress write the url : ?pagename=test&information=people
and not : test/information/people/
Why ? What's wrong ? It seems that Wordpress has a rule over mine. I don't understand ...Help !