pretty urls for categories instead of query string along with pretty pagination


I am trying to add a pretty urls instead of query string like customers/reviews/xyz here reviews is a custom post type and xyz is category
customers/reviews gives all reviews and customers/reviews/xyz gives reviews by xyz category

for this I am using rewrite_rule it works fine

here is the code for rewrite rule
function string_url_rewrite() {
global $wp_rewrite;
//add_rewrite_tag(‘%crslug%’, ‘([^&]+)’);
//In the rewrite rule you need to enter page slug and page id

        add_rewrite_rule('^customers/reviews/(?!page)([a-z-_]+)/?', 'index.php? 
        pagename=customers/reviews&crslug=$matches[1]', 'top');
    add_action('init', 'string_url_rewrite', 10, 0);

it works fine until pagination comes

when the url changes to customers/review/page/2 it’s not working I need both pretty urls for category and pagination as well
thanks in advance

, , , , Rajesh B 7 months 0 Answers 90 views 0

Leave an answer