Adding wordPress shortcode snippet to Frontity

I am trying to use a plugin for language translations in a site. The plugin provides a php shortcode <?php echo do_shortcode('[gtranslate]'); ?> that is supposed to go in the homepage index php file - it creates a dropdown selector, and when you select a language, the site is translated. I am trying to see if this plugin will work on a Frontity site, but am wondering if it’s possible to somehow use the shortcode above? It wouldn’t be able to go in the Frontity side code of course, but I’m not sure if there’s a way of creating a function.php snippet that will allow me to view the dropdown created by the snippet above in the Frontity site?

Hi @maddogdev

If you put the shortcode in the page content then Frontity will display the HTML it generates along with the rest of the content. However, in that case you need to send the value from the dropdown back to WordPress.

Take a look at this repo which shows a way to display shortcode content in Frontity. The repo is the result of this episode of Frontity Talks where we go into more detail.

This may help you with showing the dropdown in the front end of your site, but you still need to get the value of the dropdown back to WordPress. In the example above we use the Contact Form 7 package to send the form data back to WordPress. The code in that package may give you some ideas of how you can do this.

You shouldn’t need to add anything to the functions.php file unless your translation plugin is lacking something, e.g. support for Ajax.