I created a page called 'garage' on wordpress with a custom query on it. The query is in the functions.php and is used on the garage page via a shortcode. The page also has pagination using WP-PageNavi (WordPress plugin). The page accepts a parameter v to send to the custom query which gives the result. The URL query string that works look like this:
https://fakeURL.net/garage/?v=11
When there is paging it looks like:
https://fakeURL.net/garage/page/2/?v=11
I want to be able to get the same result using the following 'pretty' URL:
https://fakeURL.net/garage/11/
or
https://fakeURL.net/garage/11/page/2/
I am currently using the following but it does not work:
add_filter( 'query_vars', 'new_query_vars', 10, 1 );
function new_query_vars($vars)
{
$vars[] = 'v';
return $vars;
}
function custom_rewrite()
{
add_rewrite_rule('^garage/([0-9]+)/?', 'index.php?pagename=garage&v=$1', 'top');
}
add_action('init', 'custom_rewrite');
The above displays all the data (not the filtered one as expected) on the page and when the pagination links are clicked the URL changes as expected but the page remains on Page 1 with all the same results.
https://fakeURL.net/garage/page/2/?v=11 and https://fakeURL.com/garage/page/2/?v=11 work to get the result. I'm I missing something? I am happy with just achieving https://fakeURL.net/garage/11/. Any help would be greatly appreciated.