Replace menu tag with tag

It looks like the above can be achieved with the walker_nav_menu_start_el filter (see reference).

<?php
function edit_menu_item($item_output, $item) {
    if ( get_field( 'dropdown', $item) == 'yes' ) { 
        return '<button>'.$item->title.'</button>';
    }
    return $item_output;
}
add_filter('walker_nav_menu_start_el','edit_menu_item', 10, 2);

Credit goes to @s_ha_dum via this answer.

Leave a Comment