WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ;]

share|improve this question

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

  • Pro: there's a filter for the output of the nav menu items.
  • Contra: It can cause problems, like the nav menu not appearing on the admin UI screen, so pay attention to test this properly.

The "check nav menu items" callback function:

    function wpse18880_check_nav_menu_items( $items, $menu, $args )
        if ( is_admin() )

        echo '<pre>';
            # Show what we got:
            echo '<h3>THE MENU</h3>';
            print_r( $menu );
            echo '<hr /><h3>THE ITEMS</h3>';
            print_r( $items );
            echo '<hr /><h3>THE ARGUMENTS</h3>';
            print_r( $args );
        echo '</pre>';

        return $items;
    add_filter( 'wp_get_nav_menu_items', 'wpse18880_check_nav_menu_items', 10, 3 );

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 (via get_post_meta()) like in the follwing example should give you access to your language specific content:

// This example is for 'post' post_type menu items:
foreach ( $items as $item )
    $post_ID = $item->ID;
    // now let's overwrite the original post_title
    $item->post_title = get_post_meta( $post_ID, 'i18n_title', true );

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.