Rewrite tags aren’t used in the context of add_rewrite_rule
. If you were to use your tag in the post permalink settings under Settings > Permalinks, then your tag would be present in the link passed to the post_link
filter. I think you need to add a new permalink structure containing the tag directly to the rewrite object to have a custom tag in there. As it stands, it’s redundant since you’re already adding query vars (which add_rewrite_tag
also does). Also note that in your 2nd rule, the value of custom_category
is in $matches[1]
. For your page_link
filter, you can use the 2nd argument passed to the filter, which is the page object, to check if that page has a custom_category
and build the permalink you need in that case.
Related Posts:
- Using the Rewrite API to Construct a RESTful URL
- Dynamic Endpoints
- Rewrite Rules for Multiple (more than 2) Taxonomies
- How make a multi language routes, with rewrite rules or rewrite endpoints?
- Add rewrite rule for rewrite endpoint
- How to have multiple rewrite endpoints in the same URL?
- Custom query_vars and parse_request on wp-admin
- How to add custom variable in url without redirect?
- Rewrite URLs – Custom Post Type – Post Slug, Taxonamy Slug
- Help with rewrite rules for two post types
- Get wordpress installation folder
- WordPress Rewrite rule is not working
- How to change an existing wordpress page rewrite rule?
- wordpress path generation from rewrite rule
- add_rewrite_rule() issue with parent/child/child page
- URL Rewrite for CPT single posts
- help with rewrite_tag and rewrite_rule for custom page GET variables [duplicate]
- Rewrite URLs in a Custom Post Type with Multiple Taxonomies
- add_rewrite_rule doesn’t work when trying to add a new parameter at the end of URL
- How to create custom URL routes?
- web.config conflict on IIS
- add_rewrite_rule: $matches var not replaced by captured value
- How-to add rewrite rules to point the uploads folder to a subdomain
- add_rewrite_rule not loading correct page nor getting variables
- SEO Friendly URLs for my plugin categories
- Mod_rewrite delete parameter in 301 Redirect
- add_rewrite_rule not working for page var
- WordPress URL rewrite regex
- WordPress keeps writing rewrite rules to .htaccess
- Adding the amp url prefix to the beginning
- WordPress Rewrite
- Tricky URL rewrite with custom values in url
- Add rewrite rule to call front-page.php?
- Add a query string to ALL links on site
- Custom rewrite rule for backend/admin?
- Having trouble with using add_rewrite_rule and pagination
- add_rewrite_rule is not taking effect in WordPress? .htaccess file doesn’t update
- How to create an endpoint without creating sub endpoints?
- Add specific word to default page permalink
- Removing “category” from URLs then “add_endpoint()” won’t work…
- Rewriting URLs in WordPress
- add_rewrite_rule() to route to file other than index.php
- Rewrite rule to load images from production does nothing
- ‘rewrite_rules_array’ or ‘generate_rewrite_rules’ for adding custom rewrite rules?
- Custom rewrite not working
- My WP_options db rewrite_rules Does Not Work
- Disable Pagination on Pages
- Custom rewrite_rules – only pass numbers and not alphabetic characters
- Rewrite wp-login.php URLS to static pages?
- How to add a custom redirect rule for Post as subdomains?
- How to preserve the query string while using add_rewrite_rule and default public query vars
- Rewrite custom post type URL parameters
- Changed pagination URLS to use p= instead of paged=
- How to use add_rewrite_rule in subdomain
- Rewrite the default post object’s permalink
- URL rewriting with custom user meta “/%shop_name%/gallery/%gallery%”
- URL Rewrite and add_query_var not working
- How to add custom rewrite rules and point to specific templates
- Custom rewrite after the default term link URL
- How can I reduce the number of rewrite rules?
- Capturing /page-name/[0-99999] in both template and number
- custom wordpress rewrite
- Keep requested/entered url with add_rewrite_rule
- Name page template properly
- Rewrite Rule for homepage not working correctly
- One off rewrite for single post-type slug (show normal page with same URL instead)
- Adding Rewrite URL for Base + Children Separately
- WP redirect rule doesn’t work
- URL rewrite in theme doesn’t seem to be working
- Rewrite rule that wp-login.php?action=register is left alone
- Trying to add array of paths to post permalink
- How to rewrite URL back to default custom URL if no destination found
- Dynamic URL with rewrite rule not working
- How can I add a vanity URL for admin-ajax.php Calls?
- Remove part from dynamic url and redirect
- How to get relative page for every post: /post-1/contact. /post-2/contact
- Rewrite rule can’t get the ID from rewrited
- Pretty URL via Rewrite
- WordPress Rewrite Rule to EITHER Match 1 or 2 Taxonomies when adding to URL
- WordPress numeric (yearly) page names / disable yearly archives
- a way to support totally different url structure
- Multiple Permalink Patterns for one page
- Rewrite Rule added but showing 404 rather than specified page
- Blog List Page 404 With Custom Post Type Rewriting to Blog Parent
- Need help with custom rewrite rule
- WordPress doesn’t remember my custom rewrite rule
- Custom urls in WordPress involving page slugs
- how to change some of the rules in the database
- rewrite rules social share links
- Rewriting URLs with query strings and preserving them
- add_rewrite_rule is not fired
- Custom URL scheme – paramters on custom post type
- get_permalink is getting old rewrite rule
- Custom Rewrite for Profiles
- WordPress Custom Rewrite Rule
- Rewrite function
- Rewrite rule giving 404 error
- add_rewrite_rule not working with custom variables
- WordPress picks a wrong template if ?cat= is used as URL parameter
- How to combine nearly identical custom rewrite rules for WordPress