In your example
Change this:
public function custom_permastruct()
{
add_permastruct('language', '%lang%', false);
}
to this:
public function custom_permastruct()
{
add_rewrite_tag('%lang%','(lang)s','post_type=");
add_permastruct("language', '%lang%', false);
}
Please note that this will only work on WordPress 3.4+
Other ways of doing it:
You need to create a new permalink and after to set some rewrite rules. The function add_permastruct is a good start.
You can find a good example here: http://shibashake.com/wordpress-theme/wordpress-permalink-add and also here: https://code.tutsplus.com/articles/the-rewrite-api-post-types-taxonomies–wp-25488
That’s a media library example, but you can use the same functionality for your language module.
Related Posts:
- remove “index.php” from permalinks
- How to get pretty URLs with add_query_arg in permalinks
- Creating custom permalink structure for languages
- Getting the Site URL Including the Front Base
- Update URL Snippet to Canonical Permalink URL
- “.#[random-char-string]” being inserted at end of URLs
- URL Rewrite + Page + Custom Post Type = Unusual Redirect
- Pretty Permalinks
- How to create a permalink structure for posts in a specific category
- Remove subfolders from URL
- flexible rewrite ‘ramble’ URLs with WordPress
- Custom rewrite rules for feeds of custom queries (query_var query strings in URL)?
- How to Modify Existing Rewrite Rules?
- custom permalink/shortlink with base62 encoded post ID
- How to reset canonical URLs / fix redirect loop
- Change blog segment of URL
- Force wordpress to display page with same url structure as categories
- How can i have a custom post type with more slugs for each post?
- URL rewriting: removing the site’s basename for a specific category
- mod-rewrite exception? keep #hash in matching urls?
- Remove parent page from url
- Getting back a permalink from custom url
- Bulk append URL (add word to slug)
- Access posts while mod_rewrite is broken
- Can I change the URL structure for a CPT only?
- Multiple Taxonomy Items for Separate URLs
- WordPress keeps removing query var from the URL
- How to construct a dynamic rewrite rule for child pages that passes more than one query var
- Using a template file for a specific custom URL
- Extra url paths as variable
- Passing parameter through permalink structure
- rebuilding/ rewriting a url to make it SEO friendly
- a way to support totally different url structure
- How to change URL of my pages?
- Custom Permalink Base
- How to get the perfect WordPress, WooCommerce, Custom Post Type pretty permalinks?
- Pretty permalinks for search results with extra query var
- Using $_GET variables in the URL?
- Including category-base in a post permalink results in 404
- WordPress thinks my custom route is a 404
- Multiple post categories – single permalink
- Remove parent slug for child pages
- Limiting the number of words or characters in the slug/permalink
- custom naming of search permalink /search/
- Change website URL without breaking links or images? WP 3.3
- Random Alphanumeric Key URLs
- Rewrite URL for results of a custom WP_Query
- Using ‘Primary Category’ in URL
- How can I get the permalink of a post before it is published?
- Change permalinks with ACF values
- template_include not loading -instead goes to index.php
- Add a URL prefix to permalinks of News category and sub-categories of posts only
- Custom taxonomy rewrite using tax name instead of rewrite slug
- I need a custom permalink for my website
- Confusion about how a URL is being parsed
- Custom Post type and permalink settings
- Add custom post type name in term link?
- add_rewrite_rule not working for me
- Using WP Rewrite, but just not “getting it”
- Rewrite CPT permalinks and include WPML language
- How can I get this custom post type permalink structure? %custom_post_type%-%taxonomy%-%term-postname%
- How to include sub directory in sitemap? [closed]
- Host frontpage via example.com and everything else via example.com/blog
- WordPress can generate numeric permalinks, which then 404
- Pre-populate Slug / Permalink with URL
- Do WordPress Permalinks Refer to a Lookup Table in the Database?
- 404 error using Meta for Permalink rewrite
- Permalinks only for posts
- Permalinks settings
- How to handle paging/pagination with a custom permalink?
- Problem with parent page slug only in WordPress admin
- Custom URL rewrites for templates
- “-2” Being added to end of URL (no duplicate pages, no pages in trash)
- How to change custom post type, blog post and page permalink by template?
- Change permalinks for specific pages
- 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
- How to Use metada Value in Url and is it possible? [duplicate]
- Post with no tag permalink problem
- Custom child page permalink
- Safest way to create a custom permalink
- How do I structure my permalinks in WordPress?
- I want to rewrite the URL of a specific post with a specific custom field to easily analyze in Google Analytics
- Adding a ‘blogs’ prefix in the URL structure but only for blogs
- WordPress Attachment Page URL Rewrite!
- Customize URL for specific tags archive
- Add #primary at the end of navlink permalinks on single posts
- How to create a standard WP Page that has the same url as an archive
- How to change the URL using rewrite rule in wordpress
- Rewrite posts url as they’re all children of a page
- Get value from URL with different types of parameters
- Dynamically populate permalinks
- When using number in url it is redircting to same page but when using character it redirects to 404
- Once redirected by Rewrite rules, how can WordPress know the page?
- WordPress permalink still not working (error or not understood?)
- My wordpress site must be being affected by outside sources [duplicate]
- Change permalink in wp-property
- how to create several url aliases for a page
- Blog URL Structure – Multiple Taxonomies