First, adding a rewrite tag and a query var is redundant, adding the tag adds the query var.
Second, $matches
corresponds to each regex pattern you have in your rule, so it should be $matches[1]
and $matches[2]
, not 2 and 4.
Last, for a single member
, you can just set the member
query var.
add_rewrite_rule(
'^member/([^/]*)/book/([^/]*)/?',
'index.php?member=$matches[1]&book_name=$matches[2]',
'top'
);
Untested, but should get you going in the right direction. Also check out this rewrite analyzer plugin to help you construct your rewrite rule.
Related Posts:
- Prettified page URL w/ query var redirects to prettified page URL w/o query var
- why is are these rewrite_tags and rules not working?
- Redirect taxonomy to custom template to list terms in taxonomy
- Multiple values in a rewrite rule, is it possible?
- What add_rewrite_tag()’s RegEx matches against?
- Rewrite rules and query for virtual page
- add_rewrite_rule query_var not being set
- add_rewrite_endpoint not working
- add_rewrite_rule permalinks break in WordPress 4.5
- Rewrite Rule for Post Meta
- Why isn’t my rewrite rule working when there is no second parameter?
- WordPress add a rewrite rule to a page to accept a GET variable
- Custom Fields Query Vars and Rewrite not working
- Last query_var not working with rewritten URL
- How to use endpoint, but remove/rewrite endpoint base?
- Why does everybody hook add_rewrite_rule on init
- Regex in add_rewrite_tag not accepting OR operators?
- Querystring parameter getting lost in rewrite rule
- Rewrite Rules for Multiple (more than 2) Taxonomies
- Flush_rewrite_rules not working when settings updated
- Pagination Doesn’t Work
- Rewrite Rule for Custom Page with Query Vars in URL
- Making extra parameters optional
- How to change the matches in add_rewrite_rule
- Using add_rewrite_rule() to redirect to Front Page
- add_rewrite_rule() not working
- add_feed and flush_rewrite_rules
- custom permalink/shortlink with base62 encoded post ID
- Best action to call add_rewrite_rule
- Can rewrites fallback if 404? Rewrite conflict issue
- Custom query_vars and parse_request on wp-admin
- Associate the “add_rewrite_endpoint” and “$_GET”
- How to use rewrite rule or rewrite endpoint to switch languages?
- How to add custom variable in url without redirect?
- Remove rewrite endpoint on deactivation?
- Do I need to flush rewrite rules when creating new user if using custom author rewrite rules?
- Custom query var rewriting with only variable
- Custom rewrite_rules – only pass numbers and not alphabetic characters
- Optimal code for two add_rewrite_rule’s
- Can’t get custom rewrite tag, query var, permastruct (permalink structure), and rewrite rule to work properly together
- Rewrite URLs – Custom Post Type – Post Slug, Taxonamy Slug
- How do I flush rewrite rules
- rewrite url in wordpress
- How to add rewrite rule for external php file
- Making extra parameters optional
- My add_rewrite_rule is returning a 404
- wordpress add_rewrite_rule not working
- force_ssl_admin() causing issues with preview links
- $wp_rewrite->rules is always NULL
- Rewrite Rules problem when rule includes homepage slug
- Get wordpress installation folder
- help with custom rewrite rules
- Order of rewrite rules when calling add_rewrite_rule
- add_rewrite_rule() not stored (I think)
- custom permalink for single post category
- WordPress add_rewrite_rule second argument not working
- flush_rewrite_rules() not working on updating Settings API
- WordPress rewrite does not work for some reason
- Rewrite rules for short URL
- Adding a custom rewrite rule for gallery/categories page
- add_rewrite_rule issues
- add_rewrite_rule to search
- Rewrite rules applied differently after upgrade
- How to do make mysite.com/post-name/sub-post?
- Is it possible to add a site-wide add_rewrite_rule for a multilingual site?
- wordpress path generation from rewrite rule
- How to allow WordPress to recognize a custom URL segment after a product URL and use a custom template?
- add_rewrite_rule() issue with parent/child/child page
- WordPress – replicate same globals, query vars and query for an alternate endpoint
- add_rewrite_rule not working for blog category page
- rewrite rule not working: redirect to php script if file exists
- Rewrite post type into a page with year filter
- How to create a custom URL to another domain in WordPress
- WordPress matching URLs with trailing tildes code correction
- Pretty links with add_rewrite_rule and add_query_var
- Flush rewrite rules when every page gives 500 error?
- Using add_rewrite_rule in conditional statement using $_SERVER
- a way to support totally different url structure
- Own query vars are not displayed
- Complex rewrite rules with multiple variables, some the same
- how to use mutliple add_rewrite_rule?
- Social sharing conflict with Rewrite rules
- Adding custom slugs: parent-page/username/child-page/
- Changing default slug of post to the post id
- How bad is flush_rules() on init hook?
- Append custom parameter to taxonomy/term URI
- Custom Taxonomy in Permalink from post type
- WordPress Rewrite Rules
- help with rewrite_tag and rewrite_rule for custom page GET variables [duplicate]
- add_rewrite_rule with trailing slash redirects
- nginx + W3 Total Cache: rewrite rules issue [closed]
- add_rewrite_rule() driving me crazy, rewrite not working when analyzer says it should
- Redirect to a file in a WordPress theme directory
- Rewrite URLs in a Custom Post Type with Multiple Taxonomies
- What is the `rewrite_rules` option the options table in the WordPress database?
- add_rewrite_rule doesn’t work when trying to add a new parameter at the end of URL
- Direct domain alias to a specific WordPress page without the page in the URL
- rewriteRules WP6
- WordPress rewrite rule – not able to access second and third parameters
- Custom URL Rewrite Rules not working