• Resolved Nate

    (@goseongguy)


    Hello team,

    What would be the best way to display a language switcher or the [language-switcher] shortcode via PHP?
    I am outputting HTML in a PHP function, and it works to use
    <?php echo do_shortcode(‘[language-switcher]’); ?>
    But if I understand correctly, this is kind of silly because I’m already in the PHP environment. Can I just use a PHP TranslatePress variable instead, or a function? Something that would output the results of \wp-content\plugins\translatepress\partials\language-switcher-shortcode.php
    Or a PHP variable that stores the shortcode?

    Cheers!

    • This topic was modified 3 years, 2 months ago by Nate.
Viewing 1 replies (of 1 total)
  • Plugin Support Alex

    (@alexcozmoslabs)

    Hi,

    You can use the function, yes.

    If it helps you, the files that refer to the language switcher shortcode are:
    – wp-content/plugins/translatepress/includes/class-language-switcher.php
    ( function language_switcher )

    – wp-content/plugins/translatepress/partials/language-switcher-shortcode.php

    – wp-content/plugins/translatepress/assets/css/trp-language-switcher.css

Viewing 1 replies (of 1 total)
  • The topic ‘PHP Language Switcher’ is closed to new replies.