Google Translate in Topbar

I am trying to get the google translate plugin widget to show in the top bar to the right of my content. I can’t seem to get it to show. I found in the forums about adding the _TOPBAR.php file and did that but can’t figure out what to do next.

Hi there,

Does the Google Translate plugin have a shortcode that you can use to add it on the site? If so, we can enable the usage of shortcode in the topbar by adding this code in the functions.php file in the child theme:

add_filter('theme_x_topbar_content','x_topbar_do_shortcode');

function x_topbar_do_shortcode($content) {
 return do_shortcode( $content );
}

Once you have added the code, you can then go to the Theme Options and add the shortcode in the Topbar Content.

Hope this helps.

Ok, I removed the previous _TOPBAR.php I had added and then went and added this code to the X Child theme functions.php file. I then went into Themes, Customize, Header, the TopBar (where I have some text) and added the short code: <?php echo do_shortcode('[google-translator]'); ?> , however it still is not showing.

You do not need to add php just add the [google-translator] there in the topbar.

Ok. When I do that, I just get the tag [google-translator] showing after my text (like it is not recognizing the short code). I tried removing my text and seeing if just the short code would work but it does not. I am testing this on a test version of my site at http://tncatholic.com/ourladyoffatima if you want to take a look (if that helps any) - the live site is at http://ourladyoffatima.org

Do I need to create or put back the _topbar.php I had created. I looked through the files and that doesn’t exist in my parent theme (is it called something else in the Integrity X-Theme? - the references I saw were for the Cranium theme).

Hi there,

No, don’t add it back. Please update your code to this

add_filter('x_option_x_topbar_content','x_topbar_do_shortcode');

function x_topbar_do_shortcode($content) {
 return do_shortcode( $content );
}

Then add [google-translator] to your topbar content.

Thanks!

Ok, that worked! It is wrapping an extra line there and making the top bar pretty wide. Is that something that can be handled with css? If so, how would I do that? You can see it on my live site at: http://ourladyoffatima.org

Hi,

Yes, that can be handled with css,

You can add the following in Custom CSS

.x-topbar p:empty {
    display:none;
}

.x-topbar #google_language_translator,
.x-topbar #flags {
   display:inline-block;
}

Hope that helps.

Yes, that works! Thank you for the help!

You’re welcome.

Hi guys ,
I had this plugin on four sites and it’s not working anymore. Here’s one of my sites:
yorkshirevillageapts.com

Hi There,

That CSS code still works, I’ve just tested it on that site you provided. Where did you place the code? Please add that to Theme Options > CSS.

.x-topbar p:empty {
    display:none;
}

.x-topbar #google_language_translator,
.x-topbar #flags {
   display:inline-block;
}

Thanks,

Hi, I meant to say that this code doesn’t work:

add_filter('x_option_x_topbar_content','x_topbar_do_shortcode');

function x_topbar_do_shortcode($content) {
 return do_shortcode( $content );
}

Hi There,

Thank you for the clarification, but I see the Google translator on your site’s topbar?


Try clearing your browser’s cache, or any caching feature you might have.

Cheers!

Hey There,

Thanks for updating this thread. Regretfully the post has been withdrawn. At this time we kindly ask that you open them up in a separate thread. The longer threads get in the forum, they become more difficult to support as they tend to drift off topic and they also make it troublesome for users trying to search for solutions. Keeping threads relevant to their original inquiry ensures that we can keep better track of what has been resolved and that users can more effectively find answers to similar issues they might be experiencing.

Regards.

This was great, just what I needed! :grinning: