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
- add new permalink structure from dynamic page
- 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
- Why is add_rewrite_endpoint incompatible with /%category%/%postname%/ permalink structure?
- 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%
- 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?
- Passing the JQuery string to Worldpress URL
- Format HTTP links
- Change directory url to be same as page permalink?
- Edit permalink for certain pages
- Adding URL prefix for foreign language support
- Two URLs of one post is available
- WP-e-commerce (getshopped) – Annoying permalink issue [closed]
- IIS7.5 URL rewrite pboblem on index page
- Make a post inaccessible without a unique ID in the URL
- Create different permalinks for same post
- Why does one of my pages not have the option to edit the link?
- Permalink not changing according to post type
- WP permalink working, but why content doesn’t display
- Giving specific category posts its own permalink structure returns 404
- Flushing rewrite rules enables to see an article, but I didnt change anything
- Redirect page to homepage, keeping URL
- Adding query string to multiple page urls in a WordPress function
- I have Akamai pointing to a WordPress installation with a different URL. Is there a way to make WordPress use this for link generation?
- How can I put WordPress in a directory but keep just the home page at the domain root?
- Added a prefix in URL permalink structure but the old structure still working!
- Prevent Archive URLs
- Updates all internal links on permalink update
- how to have same rewrite rules for 2 different post type?
- What permastrusture tags are generated out of the box right after creating custom post types and taxonomies?
- How to rewrite a folder in WordPress?
- Issues with WordPress permalinks
- Why is there a # and other characters in URL for WordPress site?
- Update permalinks after domain change
- How to avoid duplicate Url for the home page
- How to shorten the Permalink after WP>WP blog import?
- Removing parent page in URL for one page
- Blog URL Structure – Multiple Taxonomies
- Display the content of another page from a specific URL