Home›Support›English Support›[Waiting for user confirmation] WPML and Custom Slug Translation for a Custom Permalinks Plugin
[Waiting for user confirmation] WPML and Custom Slug Translation for a Custom Permalinks Plugin
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
WordPress 6.7 has introduced a new issue that impact translations, please update WooCommerce and WPML to the latest versions before you report issues. More about this here - https://wpml.org/errata/php-error-wp-6-7-notice-function-_load_textdomain_just_in_time-was-called/
Background of the issue:
I am trying to use a custom plugin (Slicked Custom Permalinks) to modify the permalink structure for several custom post types (lineups, set-times, guides) that are linked to a parent post type (festivals) via JetEngine relationships. The plugin is configured to dynamically include the parent festival’s slug in the child post URLs. The desired URL structure is /translated-festivals-slug/parent-festival-slug/child-post-slug/. The plugin uses WPML to translate the base slug (festivals) into each language dynamically using wpml_register_single_string and wpml_translate_single_string. Here’s a summary of what the plugin does: Registers a Base Slug for Translation: do_action('wpml_register_single_string', 'Custom Permalinks', 'base_slug', 'festivals'); $base_slug = apply_filters('wpml_translate_single_string', 'festivals', 'Custom Permalinks', 'base_slug'); Adds Rewrite Rules: Registers rewrite rules for the translated base slug: add_rewrite_rule('^' . $base_slug . '/([^/]+)/([^/]+)/?$', 'index.php?festival=$matches[1]&name=$matches[2]', 'top'); Query Variable Handling: Adds festival as a query variable and modifies the main query to include the custom post types (lineups, set-times, guides). URL Construction: Modifies permalinks dynamically to include the translated base slug and parent festival slug: return home_url('/' . $base_slug . '/' . $parent_festival->post_name . '/' . $post->post_name . '/'); Link to a page where the issue can be seen: hidden link
Symptoms:
The translation of the base slug (festivals -> festivaluri) works correctly, and the URLs appear as expected in all languages. However, visiting the translated URLs results in a 404 Not Found error, suggesting a possible mismatch between the rewrite rules or WPML’s handling of the translated slug.
Questions:
Does WPML fully integrate with dynamically registered rewrite rules for translated slugs?
Is there a better way to register and handle the translation of the base slug to avoid 404 errors?
Are there additional steps required to ensure compatibility between WPML and JetEngine’s relationships when generating and resolving custom permalinks?
Please note we can not support or debug custom-coded plugins we can only try to advise you, if you need further help I suggest hiring a WPML contractor: https://wpml.org/contractors/
In your case using register / translate string hook, is not recomaned since this is to be used with PHP string translation not slugs. What I can suggest is to create CPT and its slug as suggested in our docs and using rewrite['slug'], then you can easily translate it from WPML > Settings.