After a bit of digging over the weekend, I found the solution and indeed, it is a rewrite rule with the paged variable added
add_rewrite_rule('collection/men/page/([^/]+)/?$','index.php?post_type=collection&men=yes&paged=$matches[1]','top');
Pagination now works in the custom template loaded by query variable. i.e. localhost/sample-site/collection/men/page/2 loads the next page instead of a 404 error
Related Posts:
- How to create custom URL routes?
- Change the “page” slug in pagination
- Passing parameters to a custom page template using clean urls
- Problem with add_rewrite_rule and pagination (paged and page query_vars)
- Using a page template without a page
- Create built-in pages without creating actual pages
- Disable wordpress pagination URL rewrite for specific page
- add_rewrite_rule not working for page var
- URL rewrites and pagination
- Rewrite Rule for Custom Page with Query Vars in URL
- Sorting archive pages with “pretty” URLs?
- custom template for custom url
- add_rewrite_rule and pagination issue
- WordPress removes spaces in URL on pagination
- WordPress rewrite rules for state and city
- How to remove WordPress category from URL and have a custom pagination parameter/rewrite?
- Remove “/page/1” from the URL
- Disable Pagination on Pages
- Load an url with minimal/no DB queries
- Custom rewrite_rules – only pass numbers and not alphabetic characters
- Changed pagination URLS to use p= instead of paged=
- Custom rewrite causes 404 on pagination
- URL rewriting with custom user meta “/%shop_name%/gallery/%gallery%”
- Adding a rewrite rule to page that has no fixed variables and pagination
- Integer based rewrite isn’t recognized for value of 1
- Not able to rewrite the pagination URL for the posts
- How can I create custom URL routes?
- Rewrite rule shows 404 page
- Why is a rewrite rule in wordpress prevent pagination?
- Query vars to return the homepage
- How to allow WordPress to recognize a custom URL segment after a product URL and use a custom template?
- WordPress pagination broken for page 2,3 with custom permalink. Redirects to baseurl
- Rewrite query var on postname
- URL rewrite before template_redirect called
- Remove trailing slash
- Redirect if string found in URL
- Pagination posts. Url format
- WordPress total posts per page changed and now 404 Http error comes out [closed]
- Wrong rewrite rules
- Need help with regex
- WordPress is adding pagination for all pages like www.example.com/page/123. How to remove that?
- `query_var` values empty in theme file after `add_rewrite_rule` redirection
- How do you create a “virtual” page in WordPress
- How to create a front end user profile with a friendly permalink
- Use a template file for a specific url without creating a page
- Using the Rewrite API to Construct a RESTful URL
- Does WordPress keep track of a post’s URL history and provide automatic redirects?
- Understanding add_rewrite_rule
- Override default url for author pages?
- web.config conflict on IIS
- Rewrite Slug for CPT Archive Pages to Plural Name of Slug
- Change author base slug for different roles
- Masking wp-content/themes/name/images to just images directory using htaccess
- Two (or more) parallel (sub-)TLDs that are retained when surfing the site / dynamically set the site address?
- Using custom/dynamic “slug” for a page
- How to make pages slug have priority over any other taxonomies like custom-post, post or category
- Rewrite rules not working in WordPress
- How to retrieve $_GET variables from rewritten URLs?
- Dynamic Endpoints
- rewrite rules and querystring
- get_query_var function not working at all
- Adding rewrite endpoint breaks static front page
- How to add custom rewrite rule to .htaccess?
- How do I remove a rewrite rule?
- How do I add a server-independent external rewrite rule?
- Multiple endpoints to same page
- How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy
- Use subdomain for certain urls
- Custom Permalinks for Blog Posts Only
- Unique URL Every Time
- generate_rewrite_rules (action) vs add_rewrite_rule (function): which one is preferred?
- Detect page type by url (Archive, single, page, author,…)
- Rewrite URL – how to do a SEO-friendly Unicode custom URL?
- I want to create a custom slug in WordPress and output JSON. How do I do this?
- How to make a category page the blog home page?
- add_rewrite_rule: $matches var not replaced by captured value
- paginate_links ignore my format
- Can I call a custom plugin with a direct URL
- How to show the same content on multiple URLs?
- Custom slug in front of search URL
- Display posts with author in the url with custom post types
- Custom rewrite rules for pages
- Rewrite default post type
- Custom permalinks with NextGEN Gallery
- Date based URLs for custom posts and pagination
- Clash of the rewrites
- External/non-WP rewrite rules
- How-to add rewrite rules to point the uploads folder to a subdomain
- Preventing index.php?category_name=something from redirecting
- Rewrite Rules for Multiple (more than 2) Taxonomies
- Changing the URL Structure of a Paginated Custom Post
- How to stop wordpress to make the default query?
- How to seamlessly redirect between different archive and singular slugs?
- Is the SEO plugin necessary?
- Can ‘numberposts’ be passed in the URL query string?
- How to add dot(“.”) in post slug
- How to prevent redirection to max 2147483647 for larger values of the page query variable?
- add_rewrite_rule not loading correct page nor getting variables
- Overwrite rewrite-slug of built in post-type ‘post’
- Preserving $_GET parameter while using custom Rewrite Rule