I have added this code to my themes functions.php
file
function custom_rewrite_rule() {
add_rewrite_rule('^shop/([^/]*)/?','index.php?page_id=1247&page=$matches[1]','top');
}
add_action('init', 'custom_rewrite_rule', 'top');
so when i browse to domain.com/shop/page1
it should rewrite to index.php?page_id=1247&page=page1
but when i do the following on page_id=1247
i get these results
echo $_GET["page"]; // = nothing
print_r($_GET) // = `Array( )`
You should get parameters with
$wp_query->query_vars
Here is an example
UPDATE
You need use
add_rewrite_tag
Also wordpress use
page
in query, so use another nameHave you flushed and regenerated the rewrite rules in the database? As stated by the docs:
Whenever you add a new rewrite rule you need to click “Save Changes” in the Permalinks admin page (even though you’re not changing anything in this page) to make sure WordPress updates the rules in the database.