The function redirect_canonical()
is ‘responsible’ for your problem.
Your default WordPress pagination (with core functions) is not gonna work if you do this, but you can filter out the pagination for your particular custom url:
add_filter( 'redirect_canonical', 'wp230913_canonical', 10, 2 );
function wp230913_canonical( $redirect_url, $requested_url ) {
if ( preg_match( "#foo/bar/[0-9]+/page/[0-9]+#", $redirect_url ) ) {
return $requested_url;
}
return $redirect_url;
}
My recomandation is to change the pagination base for the whole site, changing $wp_rewrite->pagination_base
Related Posts:
- Pagination for custom post types – url rewriting
- Paging not working for hierarchical custom post type
- Rewrite Rule & Regex – Extract ‘cat-name’ and ‘page-number’ from http://domain.com/custom-post-type/category/cat-name/page/page-number
- Custom rewrite rules for archive page and single post
- WordPress Rewrite Rules for Custom Post Type and Taxonomy
- Multiple post types – share same ReWrite slug?
- How to modify URL structures in custom post types and taxonomies or terms
- Adding meta values to permalink
- Archive page with multiple taxonomies rewrite
- Taxonomy archives based on Custom Post Type
- Change page /2 to /transcript with a Rewrite
- Permalink rewrite with custom post type and custom taxonomy
- Pagination Doesn’t Work
- Custom Post Type Rewrite Rule for Author & Paging?
- Permalinks for CPT breaks permalinks to pages
- WP Rewrite Rules – Custom post type & taxonomy
- Custom Post Type pagination when CPT ‘rewrite’ rule and a page have the same slug
- Remove base slug in CPT & CT, use CT in permalink
- WordPress Rewrite rule for nested post types
- Custom Post Type rewrite redirects to homepage
- single-{post_type}.php is not loaded despite flushing rules
- Custom Permalink Tag breaks Pagination
- Adding paged query to custom URL rewrite
- WordPress rewrite my URL when i use pagination
- Custom Post Type rewrite rules not working, how to alter the rewrite order?
- Custom Permalink for Taxonimie and Custom Post Type
- Rewrite numeric ID parameter for hierarchical custom post type
- Customising rewrite rules for CPT single post URL to work as paged URL
- Remove custom post type slug not working for child pages
- How to Combine Two Custom Post Types into Single Permalink Structure
- Permalink Structure CPT With Custom Taxonomy Fails
- Making a custom help center page
- Remove url rewrites for registered taxonomies
- Rewrite slug of custom post type to include post-id
- How to change custom post type permalink structure
- Front custom edit post page for each post
- How can I use get_post_meta with add_rewrite_rule to build custom permalinks?
- Can’t get custom rewrite tag, query var, permastruct (permalink structure), and rewrite rule to work properly together
- Rewrite Question Mark in Post Template to Make it Pretty URL
- How can achieve this permalink perfectly? domain.com/%category%/%post-name%
- Customize Custom Post Type URL
- How do I change the custom taxonomy slug to be the same as the custom post type slug?
- Custom taxonomy rewrite with query var returns %2F in URL
- WP Rewrite Rule Issue while using Custom post type & taxonomy
- Custom Permalinks with CPT and Hierarchical Taxonomies
- Rewrites/query for multiple hierarchical custom post types
- cpt and page sharing same base permalink
- Post Type rewrite rule to point to custom Page/template
- How to get list of taxonomy slugs ordered parents>childs?
- Rewrite Endpoints and CPTs – How to use in a plugin
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- add_rewrite_rule and passing variables for custom post types
- Pagination custom post type not working with rewrite slug
- WordPress custom slug rewrite
- Custom Permalinks for Custom Post Types
- Postname on unique permalink structure appends “-2” for a custom post type. How can I get this to stop happening?
- Combine multiple CPT names to create valid permalinks
- Set parent for custom post type archive rewrite url
- Route subpage to Custom Post Type
- How to rewrite custom taxonomy term archive to use THE SAME SLUG/front as CPT
- Rewrite permalink for multiple post types (CPT) with taxonomy term
- WordPress custom permalink and archive link for custom post type
- How to rewrite the post slug of a custom post type post
- rewriterule not working
- Modifying rewrite rules to use /category//
- Add Custom Values to Permalinks Through Custom Fields and Posts
- Taxonomy rewrite pagination 404
- Custom Post Type Date Based Archive URL rewrite [duplicate]
- Remove cpt slug from url and use custom taxonomy instead breaks all other cpt
- multiple URLS for the same page
- Rewrite URL for CPT to domain/post-name/post-id
- How to apply multiple rewrite_rule to a single custom post type url?
- How to properly set the rewrite rules for this case?
- Custom permalink structure for custom post types including multiple taxonomy
- CPTs relationship
- Change CPT permalink to use the category
- add_rewrite_rule wordpress ignoring url pattern, wp rewrite not working
- How to fix 404 on post after prepending Custom Post Type url with Custom Taxonomy Term slug
- Custom Post Type parent/child relationship rewrite rules for permalinks
- Redirect Custom Post Type from Child Taxonomies
- Rewrite url for custom post type with specific url
- Custom Post Type canonical link / pagination redirecting to root
- Rewrite URL of Specific Post of Custom Type
- How to build overlapping custom post_type and taxonomy rewrites without conflicts?
- Two CPT: one is using part of the custom rewrite slug from the other
- Custom post type rewrite and wp_pagenavi interfering with each other
- Custom Post Type rewrite url to /category/pagetitle [duplicate]
- WordPress custom post type rewrite rule matches all pages returning 404
- page not found for example.com/custom-post-name
- redirect old post type url to new structure url
- Archive page for a custom post type using WPML
- Why won’t this rewrite rule work?
- Parent cpt/child custom post type URL permalink relationship
- rewrite rules add a folder in the path
- Custom Taxonomy in Permalink from post type
- Custom post type permalink structure
- add_rewrite_rule not working in Custom Post Type UI Plugin
- CPT Archive Pagination – Page not found
- Custom archive URL as a subfolder of the custom post type slug
- What is the best way to relate different custom post types?