• Hello
    I’m trying to install the Google translator on a wordpress theme but I can not call it on the menu or at the top.

    I would like to add the Google Translator in the theme menu, it is very good

    Could someone help me with this task ?
    and down the code for Google translator

    —————————————-

    <div id=”google_translate_element”></div><script type=”text/javascript”>
    function googleTranslateElementInit() {
    new google.translate.TranslateElement({pageLanguage: ‘pt’, layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, ‘google_translate_element’);
    }
    </script><script type=”text/javascript” src=”//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit”></script>

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    I’ve never used this script, it appears the items to translate should be inside <div id="google_translate_element"></div>?

    How to accomplish this would depend on your theme. Many themes use a call to wp_nav_menu() to display the menu. If yours does, you can use the ‘wp_nav_menu’ filter to wrap the entire menu output inside the Google code.

    You’re really supposed to use wp_enqueue_script() to load JavaScript such as element.js, but people often get away with loading it from within a script block as Google suggests even though it’s technically wrong for WP. YMMV.

Viewing 1 replies (of 1 total)
  • The topic ‘add google translate theme wordpress’ is closed to new replies.