I’m working on a WordPress plugin that aims to solve content internationalization issues. The plugin enables users to publish content in different languages. It also offers a nice language navigation, so the visitors can switch between available languages.
I’ve already achieved a good result: the plugin adds custom fields with WYSIWYG editor (according to the languages enabled by the administrator), so it becomes less boring to edit and publish translations of posts and pages. The only problem is:
I haven’t encountered a clean implementation to provide menu internationalization. Does anyone knows how to add custom fields to the menu administration screen to translate menu itens? Or maybe an alternative manner to handle that multiple language navigation deal?
ps: I don’t intend to add any kind of tweaking to WordPress core ;]
What are nav menu items?
When you’re translating post, pages & custom post types, then i guess you’ll be also translating the titles. In general nav menu items are only posts, pages, etc. and therefore (should) come with the full content & data the post provides (if not, then you can still call the post meta).
The filter callback function
The “check nav menu items” callback function:
Modifying the menu items:
So, when looking at the output of
$item
, you’ll see that every item has it’s post-data (“or whatever it is”-data) attached. So calling the additional post data (viaget_post_meta()
) like in the follwing example should give you access to your language specific content:NOTE: I only tested the check nav menu items function, not overwriting the single items data. Please update this answer with the final code if you got it working. Thank you.