• Resolved ebarcena

    (@ebarcena)


    I’m currently using this custom language switcher to display as footer links on my website:

    <?php $array = trp_custom_language_switcher();  ?>
    <?php if ( apply_filters( 'trp_allow_tp_to_run', true ) ){ ?>
    <?php foreach ($array as $name => $item){ ?>
    <a href="<?php echo $item['current_page_url']?>">
    <span><?php echo $item['language_name']?></span>
    </a>&thinsp; &middot; &thinsp;
    <?php } ?>
    <?php } ?>

    This works fine, but it displays all languages available. How can I exclude the site’s current language from displaying?

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Anca

    (@ancavictoria)

    Hello,

    Could you please test the following code and confirm that it works as you wish?

    <?php $array = trp_custom_language_switcher();  ?>
    <?php if ( apply_filters( 'trp_allow_tp_to_run', true ) ){ ?>
    <?php foreach ($array as $name => $item){ ?>
    <?php if( $item['language_code'] != get_locale() ) : ?>
    <a href="<?php echo $item['current_page_url']?>">
    <span><?php echo $item['language_name']?></span>
    </a>&thinsp; &middot; &thinsp;
    <?php endif; ?>
    <?php } ?>
    <?php } ?>

    Kind regards,

    Anca

    Thread Starter ebarcena

    (@ebarcena)

    It works perfectly. Thank you much.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Exclude current language using the custom language switcher code’ is closed to new replies.