Changing the add_rewrite_rule
did the trick:
add_rewrite_rule('^periodicals/([^/]+)-'.$tlv['code'].'[/]?$', 'index.php?periodicals=$matches[1]&post_type=periodicals&name=$matches[1]&mlang='.$tlv['code'], 'top');
So, I assume for custom post types, using add_rewrite_rule
with index.php as query need some extra query variables. A sample will be as:
add_rewrite_rule('^<custom_post_type>/([^/]+)-'.$tlv['code'].'[/]?$', 'index.php?<custom_post_type>=$matches[1]&post_type=<custom_post_type>&name=$matches[1]&mlang='.$tlv['code'], 'top');
Related Posts:
- Rewrite Rules for Multiple (more than 2) Taxonomies
- add_rewrite_rule not working for page var
- Rewrite Rule for Custom Page with Query Vars in URL
- WordPress rewrite rules for state and city
- Custom query_vars and parse_request on wp-admin
- How to add custom variable in url without redirect?
- Custom rewrite_rules – only pass numbers and not alphabetic characters
- Rewrite URLs – Custom Post Type – Post Slug, Taxonamy Slug
- Help with rewrite rules for two post types
- Enpoint Not Found in Rewrite Tag Permalink
- 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
- Dynamic Endpoints
- How to add custom rewrite rule to .htaccess?
- How do I remove a rewrite rule?
- Problem with add_rewrite_rule and pagination (paged and page query_vars)
- How to change default page slug?
- Rewrite url for custom post type
- add_query_vars and add_rewrite_rules
- Need help with rewrite_rules_array
- Why does wordpress still strip my query var?
- When to call `add_rewrite_rule` for safety
- Custom rewrite rules are sending everything to index.php
- Rewrite rules goes away
- add_rewrite_rule again
- Rewrite Rule for Post “Subpage”, with pagination
- Need to make a php file inside theme accessible via url
- Rewrite loading custom template file but is_home() returns true, and there’s no 404
- Rewrite rule for admin-ajax.php
- Evaluating a external rewrite rule before internal wordpress rewrite rule
- Multiple Permalinks for Same Post
- add_rewrite_rule not working for language specific characters
- How to Modify Existing Rewrite Rules?
- Custom rewrite rule
- Single Redirection Rule for Pages and Archive links
- Is it possible to remove feeds from rewrites?
- Flush Rewrite Rules on init or rest_api_init?
- Remove “/page/1” from the URL
- Rewrite URL – insert custom variables as a directory path
- How to properly rewrite url by custom var
- Can’t add external rewrites
- custom template rewrite
- How to building pretty URLs to reflect category hierarchy?
- WordPress Rewrites – How can I pass a variable to Custom Post Type?
- Monkey Man Rewrite Analyzer says my rule will trigger but it doesn’t [closed]
- Need to add rewrite rule that adds in additional information about the post to url
- add_rewrite_rule is redirecting instead of rewriting url
- Help with Rewrite Rule for Custom Post Type with Query String
- Create Dynamic SEO Friendly URL for Virtual Page
- add_rewrite_rule with query variables
- Rewrite rules automatically for pages using specific template
- Custom Rewrite rule to captured post (rewrite rule to rewrite rule)
- Custom permalink leads to index page
- QSA Rewrite Rule
- How to pass url as a parameter in a add_rewrite_rule
- Per Page Permalink Structure for Page Post Type
- Customise particular RSS permalink
- ReWrite rule for files of a previously standalone blog moved to network
- RSS feed rewrite matching wrong rule
- Rewrites rules disappear after a while
- Localize URL bases
- Combine multiple CPT names to create valid permalinks
- WordPress simple Url Rewrite
- Custom rewrite rule not working
- Rewriting in wordpress url
- Add pagination to a template loaded by query variable
- Why is a rewrite rule in wordpress prevent pagination?
- How do I make WordPress revise an .htaccess file a certain way?
- Rewrite custom taxonomy slug – but only parent items
- How can I allow trailing slashes on some URLs without a redirect, but not on others?
- Can’t use a specific custom URL (slug)?
- Adding the amp url prefix to the beginning
- Rewrite rules – page does not exist
- Multiple Taxonomy Items for Separate URLs
- Rewrite WordPress Url from root to subfolder without moving files
- How to redirect to a login virtual page?
- Issue with custom rewrite for products and permalinks
- How do I rewrite URL that has custom parameter
- Help adding custom url, rewrite_rules_array
- Rewrite rule for post as a child of a CPT
- Broken page redirect
- URL Rewrite and Archive Template Files – Post Type vs. Taxonomy
- add_rewrite Rule
- rewrite rule of post when accessed from archives pages
- Migration from old CMS to WordPress 301 redirection rules?
- How to make a custom route with any-string-part/number-part pointing to an existing page?
- Using add_rewrite_tag to create urls for page sections
- Rename page URL
- Use add_rewrite_rule to change subpage url
- Need help with regex
- Rewrite Page Parameters
- wordpress category rewrite rule with pagination
- Standard Regex syntax doesn’t work in WordPress rewrite rule