Reputation: 18327
I'm currently using something like:
wp_nav_menu( array(
'theme_location' => 'primary',
'container' => false,
'items_wrap' => '<ul id="primary-main-menu" class="primary-main-menu-en">%3$s</ul>',
'fallback_cb' => false
));
Then i got a pretty decorated menu with my own class, etc.
But now another more tricky step is:
www.domain1.com
to www.domain2.com
)%3$s
thing. How to?Note:
I used walker
but i could not use walker altogether with items_wrap
option and/or the output is something distorted. So i gave up walker
. Any sharp idea please?
Upvotes: 2
Views: 2639
Reputation: 4976
Instead of defining your own Walker class you can simply hook into the default Walker using the filter walker_nav_menu_start_el
. Here you can modify the link HTML before it's outputted.
Below is a working example of your use-case:
function mytheme_walk_nav_menu_items($output, $item, $depth, $args) {
if ( $args['theme_location'] === 'primary' ) {
$output = str_replace( 'www.domain1.com', 'www.domain2.com', $output );
}
return $output;
}
add_filter( 'walker_nav_menu_start_el', 'mytheme_walk_nav_menu_items', 10, 4 );
Upvotes: 3