Tagged: Manual Switch, multi-language
-
AuthorPosts
-
July 8, 2024 at 3:27 am #1461574
I have an odd question that I’ve yet to find an answer for. We have two separate “sister” websites – one in English and one in French, both using Enfold.
We’d like to figure out a way to include a “toggle” to go back and forth between matching pages, one being in English and the other in French. We don’t want to go back to using WPML as it was problematic.
Someone suggested adding a widget or some shortcode element to each page and linking it manually. I really like the idea but don’t quite know the best way to pull it off.
Do you have any suggestions or ideas for this?
July 8, 2024 at 6:25 am #1461577Hey beverlystone,
Thank you for the inquiry.
You should be able to use custom fields to create links between pages in different languages. Here’s how:
1.) Edit the page in English (EN) language. Create a custom field named “language_switch_url” and enter the URL of the corresponding page in French (FR).
2.) Repeat this process for the page in French (FR) language, making sure you use the URL of the English (EN) page in the “language_switch_url” custom field.
3.) Finally, add the following code to your theme’s functions.php file to create a language switcher after the main menu:
add_action('ava_after_main_menu', function () { $switch_url = get_field('language_switch_url'); if ($switch_url) { ?> <div class="av-custom-language-switcher"> <a href="<?php echo esc_url($switch_url); ?>"> <?php _e('Switch to Other Language', 'avia_framework'); ?> </a> </div> <?php } }, 10, 1);
Best regards,
IsmaelJuly 8, 2024 at 7:01 am #1461579Edit: Wow – that’s really nice, Ismael.
So beverlystone – try that out first – it’s definitely more user-friendly.
________
And a landing page with a split between the two languages is not an option? After the visitor of your site decided to go to a language. You can have for the home menu-item the link to your real landing page of the website version and a backlink f.e. by flags on header_meta like the lang plugins (WPML etc.) do.
https://webers-testseite.de/pagesplit/Because, to be honest, when does a visitor choose the language of their choice? They do it at the beginning and not really at any other time.
July 8, 2024 at 1:47 pm #1461612@ Ismael – Thank you. Question: where will the language switcher appear? I see you said “after the main menu” but will that be inline with the main menu or below it?
@ Guenni007 – Thank you. I agree with you re: once a user chooses a language, they don’t switch back and forth. Still, I’m being asked to go in this direction. Either way, I will present your idea.
July 9, 2024 at 6:43 am #1461654 -
AuthorPosts
- You must be logged in to reply to this topic.