• Resolved modkid

    (@modkid)


    I use

    echo do_shortcode(‘ [elementor-template id=”24938″] ‘);

    to insert custom templates into say: my product archive. Which works great, but im now eager to start using Polylang and I can’t figure out how to make it show the right template for the right language.

    Template A – English only
    Template B – Dutch only

    Anyone know the right trigger to let the site figure out when to show which template?

    I’ve already tried something with

    // [polylang lang=”en”]English[/polylang][polylang lang=”de”]Deutsch[/polylang]
    //Add this code in your functions.php
    function polylang_shortcode($atts, $content = null)
    {
    if (empty($content))
    return ”;
    extract( shortcode_atts( array(‘lang’ => ”), $atts ) );
    if (empty($lang))
    return “### You must specify ‘lang’ using shortcode: polylang”;
    return ($lang == pll_current_language()) ? $content : ”;
    }
    add_shortcode(‘polylang’, ‘polylang_shortcode’);

    But I can’t figure out how to make it show the elementor template when the page is viewed in a certain language.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter modkid

    (@modkid)

    I did some digging and came up with the following:

    if( get_locale() == ‘en_US’) {
    echo do_shortcode(“[elementor-template id=’TEMPLATE NUMBER A’]”);
    }
    if( get_locale() == ‘nl_NL’) {
    echo do_shortcode(“[elementor-template id=’TEMPLATE NUMBER B’]”);
    }

    Seems to work. =) !

    • This reply was modified 5 years, 8 months ago by modkid.
    Plugin Author Brad Johnson

    (@p4fbradjohnson)

    Thanks for your feedback.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Insert Template into archive-product.php’ is closed to new replies.