Use add_rewrite_endpoint
instead of adding a new rewrite rule:
function wpa_chapter_endpoint(){
add_rewrite_endpoint( 'chapter', EP_PERMALINK );
}
add_action( 'init', 'wpa_chapter_endpoint' );
Related Posts:
- Passing and retrieving query vars in wordpress
- Pretty permalinks for search results with extra query var
- How to remove dates from existing permalinks?
- Getting the Site URL Including the Front Base
- Using $_GET variables in the URL?
- Including category-base in a post permalink results in 404
- WordPress thinks my custom route is a 404
- Date based URLs for custom posts and pagination
- How to custom change author base without $this->front?
- Update URL Snippet to Canonical Permalink URL
- How to prevent the default home rewrite to a static page
- “.#[random-char-string]” being inserted at end of URLs
- URL Rewrite + Page + Custom Post Type = Unusual Redirect
- Pretty Permalinks
- Remove parent slug for child pages
- How to remove the index.php in the url?
- How can I Rewrite a ‘page’ URL based on query string parameters?
- custom naming of search permalink /search/
- Rewrite user profile URL to be human friendly
- Random Alphanumeric Key URLs
- Using WP rather than .htaccess to redirect pages/posts
- Rewrite URL for results of a custom WP_Query
- rewrite_rule for custom post type doesn’t affect get_permalink
- Add ‘articles’ prefix before blog posts url without affecting pagination
- custom permalink/shortlink with base62 encoded post ID
- Change permalinks with ACF values
- template_include not loading -instead goes to index.php
- add new permalink structure from dynamic page
- WordPress not respecting template hierarchy (fetches index.php instead of single.php or page.php)
- How to improve WordPress security by hiding non public facing files?
- Call to a member function add_rule() on a non-object
- Custom taxonomy rewrite using tax name instead of rewrite slug
- I need a custom permalink for my website
- Why does chrome keep downloading a file instead of running the site?
- How can I add a page’s ID to its permalink using WP_Rewrite?
- Why is add_rewrite_endpoint incompatible with /%category%/%postname%/ permalink structure?
- Re-write specific custom post type category URL to go to another page
- Is it possible to keep all special letters for foreign languages in slug as in title?
- Change blog segment of URL
- Add custom post type name in term link?
- add_rewrite_rule not working for me
- Using WP Rewrite, but just not “getting it”
- Force wordpress to display page with same url structure as categories
- Share same Slug for a Custom Post Type and 2 Taxonomies
- Rewrite CPT permalinks and include WPML language
- Redirect a Blogger Page URL to wordpress
- How can I get this custom post type permalink structure? %custom_post_type%-%taxonomy%-%term-postname%
- IIS 7 Rewrite with parent categories
- Do WordPress Permalinks Refer to a Lookup Table in the Database?
- Passing the JQuery string to Worldpress URL
- 404 error using Meta for Permalink rewrite
- Permalinks only for posts
- mod-rewrite exception? keep #hash in matching urls?
- How to handle paging/pagination with a custom permalink?
- Format HTTP links
- Change directory url to be same as page permalink?
- Visiting posts results in 404 errors after host migration
- Custom URL rewrites for templates
- Adding URL prefix for foreign language support
- Redirecting “wrong” but working links to their canonical URL in order to prevent search engine penalties (e.g. /123/ at the end of URLs)
- How to change custom post type, blog post and page permalink by template?
- Custom permalink structure with %postname% in front of domain name
- How can I set up a secondary permalink structure?
- How to get raw unwritten querystring
- WP-e-commerce (getshopped) – Annoying permalink issue [closed]
- How to Use metada Value in Url and is it possible? [duplicate]
- How do I rewrite attachment urls when permalink structure contains %category%?
- IIS7.5 URL rewrite pboblem on index page
- Custom child page permalink
- Can I change the URL structure for a CPT only?
- Safest way to create a custom permalink
- Creating an alternate path for a page
- How to change URL from /%postname%/ to custom-name/%category%/%year%/%monthnum%/%day%/%postname%/
- Create different permalinks for same post
- Adding a ‘blogs’ prefix in the URL structure but only for blogs
- WordPress Attachment Page URL Rewrite!
- Permalink not changing according to post type
- WP permalink working, but why content doesn’t display
- WordPress Multisite ABSPATH and get_home_path() to check for htaccess or web.config file
- Flushing rewrite rules enables to see an article, but I didnt change anything
- Redirect page to homepage, keeping URL
- How can I put WordPress in a directory but keep just the home page at the domain root?
- Updates all internal links on permalink update
- how to have same rewrite rules for 2 different post type?
- Permalink structure /page/page/cpt-post gives 404 with pagination
- What permastrusture tags are generated out of the box right after creating custom post types and taxonomies?
- Rewrite posts url as they’re all children of a page
- a way to support totally different url structure
- Multiple Permalink Patterns for one page
- How to rewrite a folder in WordPress?
- Dynamically populate permalinks
- Once redirected by Rewrite rules, how can WordPress know the page?
- WordPress permalink still not working (error or not understood?)
- Custom Permalink Base
- How to change pagination base from slash to query form?
- How to shorten the Permalink after WP>WP blog import?
- how to create several url aliases for a page
- Single product link in woocomerce
- URL issues with WordPress
- Blog URL Structure – Multiple Taxonomies