WP-PageNavi permalinks and custom $_GET Variables
-
So i’m trying to use $_GET Variables with permalinks to let the user change sort order of posts.
It works fine until i try to use pagination.
So i have this function which change rewrite rule to match my custom post type “revendeurs” and add the sort value to my permalink.
So the url looks like this for example :
http://mysite.com/revendeurs/city
Meaning, it shows “revendeurs” posts sorted by “city” parameter.
Works fine for the first page then the second page link of WP-PageNavi is :
http://mysite.com/revendeurs/city/page/2
and it fails to show the results.I guess i need to update add_rewrite_rules() (see function below) when pagination is used but i don’t how to detect when there is the page parameter.
Any advice ? thx a lot !
Here is the 2 functions i use :
function add_query_vars($aVars) { array_push($aVars, 'sort'); return $aVars; } add_filter('query_vars', 'add_query_vars'); function add_rewrite_rules($aRules) { $aNewRules = array('revendeurs/([^/]+)/?$' => 'index.php?post_type=revendeurs&sort=$matches[1]'); $aRules = $aNewRules + $aRules; return $aRules; } add_filter('rewrite_rules_array', 'add_rewrite_rules');
You can find an article about that here :
http://www.janes.co.za/wordpress-permalinks-and-custom-_get-variables/
- The topic ‘WP-PageNavi permalinks and custom $_GET Variables’ is closed to new replies.