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?
- `query_var` values empty in theme file after `add_rewrite_rule` redirection
- How do I defeat the default action of a query variable on home page redirects to posts page
- When should add_rewrite_tag() be used?
- Why does everybody hook add_rewrite_rule on init
- add_rewrite_rule() vs $wp_rewrite->rules vs ‘rewrite_rules_array’?
- How to check if a rewrite rule exists
- Regex in add_rewrite_tag not accepting OR operators?
- Querystring parameter getting lost in rewrite rule
- Rewrite Rules for Multiple (more than 2) Taxonomies
- Custom post types and custom variables — add_rewrite_tag() question
- add_rewrite_rule not producing anything in $_GET
- Flush_rewrite_rules not working when settings updated
- WordPress Custom URL Rewrites
- Case-insensitive add_rewrite_rules in WordPress functions
- Does add_rewrite_rule(..) only accept “index.php” as redirect target?
- add_rewrite_rule not working for page var
- Cyrillic characters in rewrite rules cause 404 Not Found errors
- Custom Endpoint Gives 404 Header
- Clean URLs for custom $_GET variables
- Pagination Doesn’t Work
- Custom Rewrite with Query vars
- Rewrite Rule for Custom Page with Query Vars in URL
- Making extra parameters optional
- flush_rewrite_rules() cancels the effect of add_rewrite_rule()
- Separate posts by chapter per rewrite
- How to change the matches in add_rewrite_rule
- Using add_rewrite_rule() to redirect to Front Page
- resolve /author/ to a page or archive (of all authors) template
- add_rewrite_rule() not working
- Permalinks, Rewrites, Get Variables, Oh My!
- add_feed and flush_rewrite_rules
- WordPress rewrite rules for state and city
- add_rewrite_rule parameter is not received by the page
- add_rewrite_rules prefix everything
- How to Modify Existing Rewrite Rules?
- Change Theme from Plugin based on query_vars
- Can someone explain the function of the third parameter of “add_rewrite_tag”
- custom permalink/shortlink with base62 encoded post ID
- Best action to call add_rewrite_rule
- How to restore WP 5.4 behaviour where a numeric string could added to each page URL and parsed as “page” in WP 5.5?
- get_query_var with add_rewrite_rule and add_filter(‘query_vars’) not working
- Can rewrites fallback if 404? Rewrite conflict issue
- Reading Settings -> Front Page displays “Static Page” being reset
- why does add_rewrite_rule refresh and loose url variables
- Where do I USE add_rewrite_rule?
- add_rewrite_rule confusion
- add_rewrite_rule isnt working, not getting added to rules array, why?
- Custom query_vars and parse_request on wp-admin
- Associate the “add_rewrite_endpoint” and “$_GET”
- Custom Rewrite rule to match anything not already matched by WordPress
- Uppercase to Lowercase in URL
- How to use rewrite rule or rewrite endpoint to switch languages?
- How to add custom variable in url without redirect?
- Rewrite rule to prettify two $_GET variables while in a new endpoint from a page
- Remove rewrite endpoint on deactivation?
- Do I need to flush rewrite rules when creating new user if using custom author rewrite rules?
- Add Rewrite Endpoint to CPT Archive
- how to add rewrite rule to wordpress default post type
- Custom query var rewriting with only variable
- Optional all capture groups in rewrite rule
- Rewrite rule : custom post type with 2 numeric variiables
- Does it still make sense using json endpoint ep_mask now that there’s the new rest api? [closed]
- Simple page URL rewrite with add_rewrite_rule()
- Custom rewrite_rules – only pass numbers and not alphabetic characters
- Hooking “delete_option_rewrite_rules” for rewrite rule addition
- Optimal code for two add_rewrite_rule’s
- Custom URL rewrites work, but break my permalinks
- WordPress shows front page, when it should show 404 with pagination style urls
- add_rewrite_rule – Additional subpages for author pages
- 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
- Rewrite rule problem
- How do I flush rewrite rules
- add_rewrite_rule redirects if value = 1
- Pass query vars to front page
- Redirect Uploads Folder to Query Vars in WordPress
- Custom taxonomy rewrite with query var returns %2F in URL
- rewrite url in wordpress
- Custom permalink leads to index page
- How to add rewrite rule for external php file
- Help with rewrite rules for two post types
- Enpoint Not Found in Rewrite Tag Permalink
- Making extra parameters optional
- My add_rewrite_rule is returning a 404
- Rewrite rule for path of favicon.ico ( Add_rewrite_rule function possible ? )