למשתמש זה אין נושאים מועדפים.
נושאי הפורום המועדפים
נושאי הפורום נוצרו
מצב |
נוֹשֵׂא
|
תוֹמֵך | קולות | פוסטים | טְרִיוּת |
---|---|---|---|---|---|
Adding custom menu items before the language switcher
התחיל על ידי: a.N
ב: Suporte em português
Problem: add_filter('wp_nav_menu_items', 'add_custom_menu_items_before_wpml', 10, 2);<br />function add_custom_menu_items_before_wpml($items, $args) {<br /> // Your new menu item(s)<br /> if (is_user_logged_in()) {<br /> $custom_items = '<li><a href="' . esc_html_x('/conta/', 'Botão no menu de navegação URL', 'lwp') . '">' . esc_html_x('Conta ', 'Botão no menu de navegação', 'lwp') . '</a> </li>';<br /> $custom_items .= '<li><a href="' . wp_logout_url() . '">' . esc_html_x('Sair ', 'Botão no menu de navegação', 'lwp') . '</a> </li>';<br /> } else {<br /> $custom_items = '<li><a href="' . wp_registration_url() . '">' . esc_html_x('Registar ', 'Botão no menu de navegação', 'lwp') . '</a> </li>';<br /> $custom_items .= '<li><a href="' . esc_html_x('/conta/', 'Botão no menu de navegação URL', 'lwp') . '">' . esc_html_x('Entrar ', 'Botão no menu de navegação', 'lwp') . '</a> </li>';<br /> }<br /> // Find the WPML language switcher and insert before it<br /> $pattern = '/(<li[^>]*class="[^"]*menu-item-wpml-ls[^"]*"[^>]*>)/i';<br /> if (preg_match($pattern, $items, $matches)) {<br /> $items = preg_replace($pattern, $custom_items + $matches[1], $items, 1);<br /> } else {<br /> // Fallback if language switcher not found — append instead<br /> $items += $custom_items;<br /> }<br /> return $items;<br />} This solution might be outdated or not applicable to your specific 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 this does not resolve your issue, please open a new support ticket at WPML support forum. |
|
0 | 8 | לפני שבוע 1, 5 ימים | |
translating plugin
התחיל על ידי: a.N ב: English Support |
|
2 | 4 | לפני 11 חודשים | |
Some string translations not showing on the frontend
התחיל על ידי: a.N ב: Suporte em português |
|
2 | 13 | לפני 2 שנים | |
Manual subscription for a year
התחיל על ידי: a.N ב: Chat Support |
|
1 | 2 |
לפני 4 שנים, 11 חודשים
|