למשתמש זה אין נושאים מועדפים.
נושאי פורום מועדפים
נושאי פורום שנוצרו
| סטטוס |
נושא
|
תומך | קולות | פוסטים | עדכניות |
|---|---|---|---|---|---|
|
Get content of translated menus
נפתח על ידי: sebastienV-8
ב: English Support
Problem: wp_get_nav_menu_object() and wp_get_nav_menu_items() functions, but these functions are returning the content in the original language instead of the translated language. Solution:
To solve the issue, you can use the wpml_switch_language hook to switch the language before retrieving the menu objects and items. Here is an example code snippet:
$my_current_lang = apply_filters( 'wpml_current_language', NULL );
// Switch to Italian (IT)
do_action( 'wpml_switch_language', "it" );
// Now retrieve the menu object and items in Italian
$menu = wp_get_nav_menu_object($menu->term_id);
$items = wp_get_nav_menu_items($menu->term_id, array('post_status' => 'any'));
// Switch back to the original language
do_action( 'wpml_switch_language', $my_current_lang );If this solution does not seem relevant to your issue, please open a new support ticket at WPML Support Forum. |
|
2 | 8 | לפני שנה 1, חודש 11 |