Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter schw0722

    (@schw0722)

    It never fails: post a question on a forum, and within an hour you figure it out yourself.

    So for anyone else looking, here’s the solution:

    The nav_menu_item object has a property named ‘object_id’, which is actually the ID for the original page. So can grab that ID, and then get that original page, which qTranslate has no problem with.

    Here’s the code:

    $menuName = 'home-page';
    $args = array(
    	'theme-location' => $menuName,
    	'depth' => 1
    );
    $locations = get_registered_nav_menus();
    $menu = wp_get_nav_menu_object( $locations[ $menuName ] );
    $menu_items = wp_get_nav_menu_items($menu->term_id, $args);
    $menu_items = apply_filters( 'get_pages', $menu_items );
    
    $output = '';
    foreach ($menu_items as $item) {
    	// qTRANSLATE HACK:
    	// Get actual page (type='page' not'nav_menu_item' <-- qTranslate is unable to directly translate nav_menu_items)
    	$page = get_page($item->object_id);
            $content = apply_filters('the_content', $page->post_content);
            $output .= $content;
    }
    echo $output;

    Yes, I’m doubling the number of calls to the server, so it might slow the page down a bit, but it works.

Viewing 1 replies (of 1 total)