Skip Navigation

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

Problem:
The client needed to activate only 3 specific languages on certain pages using WPML, while keeping other pages with the full set of languages. They also requested documentation for the languages array and information on variables inside

[wpml_language_switcher]

and

[wpml_language_selector_widget]

shortcodes, as well as how to get the current language flag URL outside of the shortcode using PHP.

Solution:
We recommended the client to review the following documentation:

Additionally, we suggested checking our hooks reference for more advanced customization options: WPML hooks reference.

If the provided solution is not relevant due to being outdated or not applicable to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please open a new support ticket in our forum: WPML support forum.

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 3 replies, has 2 voices.

Last updated by Osama Mersal 10 months ago.

Assisted by: Osama Mersal.

Author Posts
February 29, 2024 at 11:01 am #15357395

kalleV-3

Hello,
We can use all the languages we define on all WP pages via WPML (for example, 10+ languages). How can I activate 3 specific languages only on certain pages? For example, I have a blog page, I want to activate only 3 languages on this blog page via WPML. I want to leave the other pages as they are, like the homepage, for example 10+ languages/

February 29, 2024 at 11:15 am #15357514

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Thanks for contacting WPML forums support. I'll be glad to help you today.

You can activate the 10 languages in WPML-> Languages. When you translate a page like the home page, you can translate it into 10 languages, and if you want a page or post to be translated to only some languages, please translate it to these languages only.

In this case, the language switcher will show only the translated languages, but you can't disable /enable languages for specific posts/pages.

Best regards,
Osama

March 11, 2024 at 12:17 pm #15394933

kalleV-3

Hi Osama,

I managed to find a snippet to restrict the usage only for specific languages.
Can you advise where is the documentation for the languages array ? Where can I find more information what variables are inside [wpml_language_switcher] and [wpml_language_selector_widget] ?
Can I edit [wpml_language_selector_widget] similarly ?
Also, how do I get current language flag URL outside from the shortcode via php ?

[wpml_language_switcher]
<div class="{{ css_classes }} my-custom-switcher">

</div>
[/wpml_language_switcher]

March 11, 2024 at 12:26 pm #15394962

Osama Mersal
Supporter

Languages: English (English ) Arabic (العربية )

Timezone: Africa/Cairo (GMT+02:00)

Hi,

Please check the following guides:

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

2- https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/custom-language-switcher/

Also, please check our hooks reference. (https://wpml.org/documentation/support/wpml-coding-api/wpml-hooks-reference/)

Kindly let me know if the above resources helped you fix the issue.

Best regards,
Osama

March 15, 2024 at 4:38 pm #15415422

kalleV-3

Thanks, created a custom Shortcodes based on what I copied here before.