-
AuthorPosts
-
January 13, 2021 at 10:30 am #1272087
I have a webpage with tabs and the tab titles have accents (they are written in French – using WPML). The links are automatically generated by removing the letters that have the accent. For example, when having ‘Préparation’ as tab title, the link becomes ‘/prparation’. I would prefer that the link contains all the letters without the accents (so, in this case, ‘/preparation’). Would it be possible? Thank you!
- This topic was modified 3 years, 11 months ago by albertgarduno.
January 17, 2021 at 10:14 pm #1273163Hey albertgarduno,
Sorry for the very late reply, try adding this code to the end of your functions.php file in Appearance > Editor:function custom_script() { ?> <script> (function($){ $(document).ready(function(){ $('html[lang="fr-FR"] #av-tab-section-1 > div > div.av-tab-section-tab-title-container a:first').each(function(){ var tabtitle = 'preparation'; $(this).attr('href', '#' + tabtitle); }); }); })(jQuery); </script> <?php } add_action('wp_footer', 'custom_script');
Then clear your browser cache and check.
Best regards,
MikeJanuary 20, 2021 at 7:02 pm #1274164Hi Mike,
Thank you for your reply. I thought there could be an easier way to do it than editing the functions.php file. Also, because it’s not only the “preparation” tab but also the rest of the French ones. And in the future, there could be others. Is there anyway to edit those slugs without editing the functions.php file?
Thank you in advance.
Best,Albert
January 22, 2021 at 12:39 pm #1274667Hi,
Sorry for the late reply and good point, sorry I misunderstood. I have submitted this issue to the dev team for review and will reply when we hear back from the dev team. Thank you for your patience.Best regards,
MikeJanuary 24, 2021 at 12:16 am #1275004Hi,
Thank you for your patience, the dev team writes that this would not be able to be added to the core, but you can use a filter to adjust the tab section link, so for the examplePréparation
, the filter to add to your functions.php is:add_filter('avf_save_string_translated','avf_save_string_translated_mod'); function avf_save_string_translated_mod($link){ if (strpos($link, 'prparation') !== false) { return 'preparation'; } else {return $link;} }
you will note in the example the filter is looking for the text
prparation
, this is because at this point WordPress has already striped theé
away. I tried to add a character conversion to the filter but I was not successful.Best regards,
MikeJanuary 25, 2021 at 11:49 am #1275231Thank you Mike, I will try it this week. If I have any issue, I will let you know.
Best,Albert
January 25, 2021 at 1:11 pm #1275251Hi,
Very good, the dev team has also added two new filters in the next update:added: filter ‘avf_tab_section_link_hash’: filter hash value for ALB tab section (e.g. replace non ASCII with custom value instead of removing)
added: filter ‘avf_valid_href’: allows to replace invalid removed charactersThe filter above should continue to work, or you could use this filter with v4.8:
add_filter('avf_tab_section_link_hash','avf_tab_section_link_hash_mod'); function avf_tab_section_link_hash_mod($link){ if (strpos($link, 'prparation') !== false) { return 'preparation'; } else {return $link;} }
We believe the next update will be around the end of Jan.
Best regards,
MikeJanuary 25, 2021 at 1:16 pm #1275253Hi Mike,
Thanks for the information! So, if I understood correctly, at the end of this month there will be an update that will solve my issue, right? Then, I will just wait for it :)
Best,
Albert
January 25, 2021 at 3:02 pm #1275272Hi,
Not exactly, in my tests with the beta, by the time the text is in the filter theé
has already been removed, so using regex to replace theé
, or any non ASCII character won’t work, thus the searching for the word missing the characterprparation
in the filter above.
But the I am encouraged by the update notes, posted above, because the beta I’m testing with is not the final version.Best regards,
Mike -
AuthorPosts
- You must be logged in to reply to this topic.