Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #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?

    #1461577

    Hey 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,
    Ismael

    #1461579

    Edit: 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.

    #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.

    #1461654

    Hi,

    Thank you for the inquiry.

    Question: where will the language switcher appear?

    The switcher should appear beside the main menu, but it can be adjusted with css, or we can reposition it using a different template hook. Let us know if you need any adjustments.

    Best regards,
    Ismael

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.