Skip to content Skip to sidebar

This thread is resolved. Here is a description of the problem and solution.

Problem:
After upgrading to WP 6.4, Timber 2.0, and PHP 8.1.14, the client encountered a fatal error when trying to display the custom language switcher using the

{% do action('icl_language_selector') %}

code.
Solution:
We recommend using the updated code:

do_action('wpml_add_language_selector')

For more information, please refer to our documentation on adding language switchers using PHP.

If this solution doesn't look relevant to your issue, please open a new support ticket in our support forum.

100% of people find this useful.

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 1 reply, has 2 voices.

Last updated by Christopher Amirian 1 year, 9 months ago.

Assisted by: Christopher Amirian.

Author Posts
November 13, 2023 at 3:17 pm #14790647

Joris Rijpma

I just upgraded WP to 6.4 and Timber 2.0 and PHP 8.1.14

When trying to display the custom language switcher I've got an error.
It looks like i'm missing an argument in this piece of code:

{% block languageswitcher %}
{% do action('icl_language_selector') %}
{% endblock %}

But icl_language_selector does not support any argument.

The upgraded project is running local so i can't give any access

ERROR:

Fatal error: Uncaught ArgumentCountError: Too few arguments to function WPML_LS_Actions::callback(), 0 passed in /app/public/wp-includes/class-wp-hook.php on line 310 and at least 1 expected in /app/public/wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/public-api/class-wpml-ls-actions.php:24 Stack trace: #0 /app/public/wp-includes/class-wp-hook.php(310): WPML_LS_Actions->callback() #1 /app/public/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters('', Array) #2 /app/public/wp-includes/plugin.php(565): WP_Hook->do_action(Array) #3 /app/public/wp-content/themes/expedition-theme/vendor/timber/timber/src/Twig.php(51): do_action_ref_array('icl_language_se...', Array) #4 /app/public/wp-content/themes/expedition-theme/vendor/twig/twig/src/Environment.php(361) : eval()'d code(134): Timber\Twig->Timber\{closure}('icl_language_se...') #5 /app/public/wp-content/themes/expedition-theme/vendor/twig/twig/src/Template.php(171): __TwigTemplate_a3091c09be125f338e2a2acc41399e67->block_languageswitcher(Array, Array) #6 /app/public/wp-content/themes/expedition-theme/vendor/twig/twig/src/Environment.php(361) : eval()'d code(121): Twig\Template->displayBlock('languageswitche...', Array, Array) #7 /app/public/wp-content/themes/expedition-theme/vendor/twig/twig/src/Template.php(394): __TwigTemplate_a3091c09be125f338e2a2acc41399e67->doDisplay(Array, Array) #8 /app/public/wp-content/themes/expedition-theme/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array) #9 /app/public/wp-content/themes/expedition-theme/vendor/twig/twig/src/Environment.php(361) : eval()'d code(72): Twig\Template->display(Array) #10 /app/public/wp-content/themes/expedition-theme/vendor/twig/twig/src/Template.php(394): __TwigTemplate_d1c3b44367922f28d8bc1f80d0643b4f->doDisplay(Array, Array) #11 /app/public/wp-content/themes/expedition-theme/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array) #12 /app/public/wp-content/themes/expedition-theme/vendor/twig/twig/src/Environment.php(361) : eval()'d code(50): Twig\Template->display(Array) #13 /app/public/wp-content/themes/expedition-theme/vendor/twig/twig/src/Template.php(394): __TwigTemplate_5379173119ad4ad6d583e6f775c554c3->doDisplay(Array, Array) #14 /app/public/wp-content/themes/expedition-theme/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array) #15 /app/public/wp-content/themes/expedition-theme/vendor/twig/twig/src/Environment.php(361) : eval()'d code(42): Twig\Template->display(Array, Array) #16 /app/public/wp-content/themes/expedition-theme/vendor/twig/twig/src/Template.php(394): __TwigTemplate_bc9ddc3aba40969613eb42af37e7d09d->doDisplay(Array, Array) #17 /app/public/wp-content/themes/expedition-theme/vendor/twig/twig/src/Template.php(367): Twig\Template->displayWithErrorHandling(Array, Array) #18 /app/public/wp-content/themes/expedition-theme/vendor/twig/twig/src/Template.php(379): Twig\Template->display(Array) #19 /app/public/wp-content/themes/expedition-theme/vendor/twig/twig/src/TemplateWrapper.php(40): Twig\Template->render(Array, Array) #20 /app/public/wp-content/themes/expedition-theme/vendor/timber/timber/src/Loader.php(178): Twig\TemplateWrapper->render(Array) #21 /app/public/wp-content/themes/expedition-theme/vendor/timber/timber/src/Timber.php(1442): Timber\Loader->render('page.twig', Array, false, 'default') #22 /app/public/wp-content/themes/expedition-theme/vendor/timber/timber/src/Timber.php(1579): Timber\Timber::compile(Array, Array, false, 'default', true) #23 /app/public/wp-content/themes/expedition-theme/page.php(29): Timber\Timber::render(Array, Array) #24 /app/public/wp-includes/template-loader.php(106): include('/app/public/wp-...') #25 /app/public/wp-blog-header.php(19): require_once('/app/public/wp-...') #26 /app/public/index.php(17): require('/app/public/wp-...') #27 {main} thrown in /app/public/wp-content/plugins/sitepress-multilingual-cms/classes/language-switcher/public-api/class-wpml-ls-actions.php on line 24

November 14, 2023 at 6:34 am #14793581

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi there,

Please use the newer code instead of the one you used:

do_action('wpml_add_language_selector')

For more information:

https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/adding-language-switchers-using-php-and-shortcodes/#language-switchers-using-php

Thanks.