Add dynamic var into "link_before/after" in wp_nav_menu, possible?
-
The reason is that I would like to show both languages on each items of the menu. I want to have nested code without re-write the whole menu thing by HTML(if possible..) , but based on wp_nav_menu.
Now i could only display the second language on each item separately from the menu via hooking wp_nav_menu_objects.
add_filter( 'wp_nav_menu_objects', 'lang_menu' ); function lang_menu( $items ) { foreach ( $items as $item ) { $post = get_page($item->object_id); $title = qtrans_use('fr', $post->post_title,false); } return $items; }
Is it possible to take the var into the wp_nav_menu on each item in link_before/after as something like this?
'link_before' => $items[$i], //$items - second languages items //$i - something like loop counter in wp_nav_menu on each item (I know it doesnt exist in core..)
wp_nav_menu reference:
wp_nav_menu($arg); $arg = array( 'theme_location' => 'header-menu', 'menu' => 'nav', 'container' => 'div', 'container_class' => 'menu-{menu slug}-container', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '', 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul>%3$s</ul>', 'depth' => 0, 'walker' => '' );
———
Is it possible to add dynamic var into “link_before/after” in wp_nav_menu?
Or I need to make it happen by other measures? thanks a lot. gratitude for any attentions and helps.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Add dynamic var into "link_before/after" in wp_nav_menu, possible?’ is closed to new replies.