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

Last updated by Riffaz 9 months, 1 week ago.

Assigned support staff: Riffaz.

Author Posts
October 15, 2019 at 12:06 pm #4757105

Jon

Hi Raja,

I see you answered a user with a similar problem previously, providing PHP for their functions.php file.

I simply want to change the WPML dropdown menu so that the top level item (i.e. the current language) only triggers the drop down menu and doesn't behave as a link itself.

When a user is on a touch screen, it's very difficult for them to change languages as clicking on the language dropdown reloads the page and they can't see the other items in the dropdown.

Hope you can assist here
Thanks

October 16, 2019 at 8:17 am #4763187

Jon

Is anyone going to help with this?

October 16, 2019 at 11:45 am #4765287

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

Thank you for contacting WPML support.

Did you try to this option? (list): hidden link
Are you asking about something else?
Could you please show an example of what you are asking about?

Regards,
Riffaz.

October 17, 2019 at 6:57 am #4770495

Jon

Thanks for the response Riffaz.

Unfortunately it needs to be a drop down for this menu; a list would be too long.

If you go to hidden link you'll see that the last menu item is the language dropdown with the top menu item being the current language.

All I want to do is change it so that the top menu item doesn't behave like a link, it only triggers the dropdown, similar to when you create a 'Custom Link' in a normal WordPress menu item with the '#' as the URL - it just triggers the dropdown.

Thanks, hope you can assist here

October 17, 2019 at 9:26 am #4771631

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

Do you have a place to add JavaScript in your theme options?
If yes, add this code there

jQuery('#menu-item-wpml-ls-89-ja a.sf-with-ul').css("pointer-events", "none");

if that does not work add this to the bottom of your functions.php

function disable_link_wpml_switcher() {
    ?>
        <script>
          jQuery('#menu-item-wpml-ls-89-ja a.sf-with-ul').css("pointer-events", "none");
        </script>
    <?php
}
add_action('wp_footer', 'disable_link_wpml_switcher');

Now check the issue.
Does that help?

Let me know.

Regards,

October 17, 2019 at 3:03 pm #4775247

Jon

Thanks again,

But unfortunately neither of those seem to work. Can you think of any other options here?

Most appreciated

October 21, 2019 at 5:27 am #4791113

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

Add this code to your functions.php

function disable_link_wpml_switcher() {
    ?>
        <script>
          jQuery('.wpml-ls-current-language > a.sf-with-ul').on('click',function(e){e.preventDefault();});
        </script>
    <?php
}
add_action('wp_footer', 'disable_link_wpml_switcher');

Let me know how it goes.

Regards,

October 21, 2019 at 1:38 pm #4794953

Jon

Thanks again Riffaz,

I placed this at the bottom of functions.php, cleared all caches, but the current language / top level of the WPML menu is still working as a normal link, not just triggering the drop down to access the other languages...is there something else in the code we can change maybe?

Thanks for your assistance here - most appreciated

October 22, 2019 at 1:14 pm #4802767

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

Both code work in my testing site.
Let me know your site login details to check this closely.
The next reply is private.

Regards,

October 27, 2019 at 12:28 pm #4834407

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

Hi,

Thank you for the details.

I tried different combinations of the code for the same purpose.
None of these work in your site. The test code very fine in my local sites.
Something from your theme or plugin is overriding the javascript code you add in your functions.php

I added another submenu to your menu here: hidden link
That also has the same issue.
This menu does not come from WPML obviously.
So you can understand that this behaviour is not controlled by the WPML

Please ask the same question to your theme support and show the code we provided.
And, ask them to check both the test submenu hidden link and the WPML menu.
They can point to you to the right direction as this behaviour is same for all the sub menu in your site.. not only for WPML language switcher.

Let me know how it goes.

Regards,

October 28, 2019 at 10:43 am #4838387

Jon

Ok, thanks for taking a look - I'll talk with them

October 29, 2019 at 7:34 am #4844225

Riffaz
Supporter

Languages: English (English )

Timezone: Asia/Colombo (GMT+05:30)

You are welcome.

Let me know if you need anything else regarding this after checking with your theme support.

I am updating the status.

Regards,

The topic ‘[Closed] Change top menu item to only trigger dropdown, not as a link’ is closed to new replies.