Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 4 replies, has 2 voices.

Last updated by robertoM-8 6 months ago.

Assigned support staff: Andreas W..

Author Posts
February 13, 2020 at 12:23 pm #5485841

robertoM-8

I have a multisite
main:
digital-dentistry.org
and subsites:
pl.digital-dentistry.org

Link to a page where the issue can be seen:
pl.digital-dentistry.org/partners

I created a template on the main website.
in the functions.php there is a shortcode such as

function dds_global_partners_widget()
{
    global $switched;
    switch_to_blog(1);
    $output = do_shortcode('[elementor-template id="31450"]');
    restore_current_blog();
        return $output;
}
add_shortcode('dds_global_partners_widget', 'dds_global_partners_widget');

This way all the websites can import the widget by using a shortcode, and use it in Elementor in every website.

In all the websites where there is only one language, it works perfectly

In the websites where there are two languages or more, this happens

[13-Feb-2020 11:57:16 UTC] PHP Notice:  Undefined property: WP_Error::$taxonomy in /home/srvrfrm1/public_html/digital-dentistry.org/wp-content/plugins/elementor-pro/modules/query-control/classes/elementor-post-query.php on line 226
[13-Feb-2020 11:57:16 UTC] PHP Notice:  Trying to get property 'ID' of non-object in /home/srvrfrm1/public_html/digital-dentistry.org/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/page-builders-elementor/src/class-wpml-elementor-urls.php on line 31
[13-Feb-2020 11:57:16 UTC] PHP Fatal error:  Uncaught InvalidArgumentException: Argument ID must be numeric and greater than 0. in /home/srvrfrm1/public_html/digital-dentistry.org/wp-content/plugins/sitepress-multilingual-cms/classes/translations/class-wpml-translation-element.php:28
Stack trace:
#0 /home/srvrfrm1/public_html/digital-dentistry.org/wp-content/plugins/sitepress-multilingual-cms/classes/translations/class-wpml-translation-element-factory.php(41): WPML_Translation_Element->__construct(NULL, Object(SitePress), NULL)
#1 /home/srvrfrm1/public_html/digital-dentistry.org/wp-content/plugins/sitepress-multilingual-cms/vendor/wpml/page-builders-elementor/src/class-wpml-elementor-urls.php(31): WPML_Translation_Element_Factory->create_post(NULL)
#2 /home/srvrfrm1/public_html/digital-dentistry.org/wp-includes/class-wp-hook.php(288): WPML_Elementor_URLs->adjust_edit_with_elementor_url('<em><u>hidden link</u></em>...', Object(ElementorPro\Modules\ThemeBuilder\Documents\Section))
#3 /home/srvrfrm1/public_html/digital-dentistry.org/wp-includes/plugin.php(206): WP_Hoo in /home/srvrfrm1/public_html/digital-dentistry.org/wp-content/plugins/sitepress-multilingual-cms/classes/translations/class-wpml-translation-element.php on line 28
February 13, 2020 at 11:06 pm #5490439

Andreas W.
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Thank you for contacting the WPML Support Forum.

The method you are using to implement the template might work well for the default language, but with WPML such Elementor templates will need to be translate din order to be used on translated pages and this will result in a different shortcode ID.

A solution would be to translate the templates and use their shortcodes in an "elseif" statement while referring to the matching ICL_LANGUAGE_CODE

An example:

https://wpml.org/forums/topic/do_shortcode-based-on-chosen-language/

More information can be found in our hook reference.

https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/

Kind regards
Andreas

February 14, 2020 at 8:23 am #5492497

robertoM-8

In the Main website WPML is not active.

Therefore i cannot create a translatable widget.
Also, the widget should not be translated since theres only images.

Can i force somehow the subsite (which has multiple languages) to load only the "one" widget from the main site (which has only one language)??

Plus, as you can see the widget is correctly loaded. But the page shows strangely (it's small than the viewport)
hidden link

Thanks

February 14, 2020 at 9:16 am #5493031

robertoM-8

I went on the Main Website (where the Widget is), went in WPML Options, and made the elementor templates NOT TRANSLATABLE.

This fixed my issue

February 14, 2020 at 9:16 am #5493123

robertoM-8

My issue is resolved now. Thank you!