I am building a website with WordPress, using it more like a CMS and then a blogging platform. I have used many custom post types and custom taxonomies. Last but not least, I made it multilingual using the WPML plugin.
In CPT declarations, I wrapped the lines and bullets in gettext so that they are translated into WPML.
An example CPT ad is as follows:
register_post_type('rooms', array( 'label' => __('Rooms','valletta'), 'description' => __('','valletta'), 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'capability_type' => 'post', 'hierarchical' => true, 'rewrite' => array('slug' => __('rooms','valletta')), 'query_var' => true, 'exclude_from_search' => false, 'menu_position' => 25, 'supports' => array('title','editor','excerpt','custom-fields','comments',), 'taxonomies' => array('features','typology',), 'labels' => array ( 'name' => __('Rooms','valletta'), 'singular_name' => __('room','valletta'), 'menu_name' => __('Rooms','valletta'), 'add_new' => __('Add room','valletta'), 'add_new_item' => __('Add New room','valletta'), 'edit' => __('Edit','valletta'), 'edit_item' => __('Edit room','valletta'), 'new_item' => __('New room','valletta'), 'view' => __('View room','valletta'), 'view_item' => __('View room','valletta'), 'search_items' => __('Search Rooms','valletta'), 'not_found' => __('No Rooms Found','valletta'), 'not_found_in_trash' => __('No Rooms Found in Trash','valletta'), 'parent' => __('Parent room','valletta'), ) ) );
As you can see, I also wrapped the term slug, and this (for me) makes sense. What I wanted to achieve was that when the user visits the βstandardβ website in Italian, he will reach the CPT page in the room via / camere / nome -camera /, while the English user will receive it / rooms / room -name /. This works well for Italian, and WPML translates slug correctly for the English version, so if I look at the CPT number on the Italian website and I switch to the English version, WordPress is ported to / rooms / with the only problem, shows 404.
I checked the WPML website and they acknowledge that the translation of slugs is still ongoing, and that is the functionality that is likely to be released with the next version of the plugin. Ok, that's fine.
What I'm trying to achieve is a hack, and WPML updates are a plugin. My idea is to have some custom rewrite rules in my .htaccess and rewrite the URL of these CPT pages. I thought that I could remove the slug translation to have one slug for both languages, and then have a rewrite rule that when someone enters a translated slug, is βstandardβ instead, but at least the content is correct , and: a) the user will not notice anything, since the browser does not redirect the page, but simply rewrites the URL, and b) nothing changes for WP (or is it so?).
So the question is: how can I do all this? Removing the translation of the plugins is okay, just deleting it on the WPML server, but itβs not very convenient for me to rewrite the rules and the like, so I'm looking for someone who could help me achieve my goal and, ultimately, show the best way to achieve that what I need (and, of course, to have feedback if my idea makes sense or not).
Sorry if I missed something. If you need more information, I am here to give them.