Reputation: 12578
I am trying to use URL parameters for pagination within WordPress for a custom post type
. The current URL is...
example.com/my_custom_post_type/page/2
And I am trying to make it look like this...
example.com/my_custom_post_type&page=2
I have tried to set a rewrite rule in my htaccess like so...
RewriteRule ^page/([^/]*)/$ /?page=$1 [L]
But this is not working for me, can anyone see where I am going wrong?
Upvotes: 0
Views: 398
Reputation: 12578
Managed to work this one out in the end by disabling the cononical redirect for pagination queries like this...
add_filter( 'redirect_canonical', function ( $redirect_url ) {
if ( is_paged() ) {
return false;
}
return $redirect_url;
}, 10, 1 );
Upvotes: 1
Reputation: 133458
Could you please try following, based on your shown samples. Please make sure you clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ $1&$2=$3 [L]
Upvotes: 1