Theme OceanWP: Use language selector in the main menu
How to fix the language selector in mobile menu of OceanWP theme
To create the mobile menu, the OceanWP theme duplicate the main menu with modified attribute. To fix Weglot language selector on this mobile menu, you must add the following code into your functions.php file. It's add JavaScript code into your page to fix this modified attribute.
Theme OceanWP website : https://oceanwp.org/
1
<?php
2
3
add_action( 'wp_footer', 'weglotsupport_wpocean_menu' );
4
function weglotsupport_wpocean_menu() {
5
?>
6
<script type="text/javascript">
7
/* WEGLOT FIX WP OCEAN MENU */
8
jQuery(document).ready(function ($) {
9
var weglotMenuDone = false;
10
jQuery(document).on('click', '.oceanwp-theme .mobile-menu', function() {
11
if (weglotMenuDone) {
12
return;
13
}
14
jQuery(".sidr-class-weglot-flags").each(function() {
15
if ( typeof jQuery(this).attr("class") !== 'undefined' ) {
16
var element_class = jQuery(this).attr("class");
17
jQuery(this).addClass( element_class.replace(/sidr-class-/g, ''));
18
}
19
});
20
weglotMenuDone = true;
21
} );
22
});
23
</script>
24
<?php
25
}
Copied!
Last modified 1yr ago
Copy link