0

I'm making a mega-menu with some menu-items that can have a more rich content (from a wysiwyg editor using ACF custom fields).

So, i have set an ACF field group to work with menu items, i need that content to show instead of the default menu content (if there is some content specified for that menu item), otherwise, just show the default output of the menu item.

For this, i used a walker and overrode start_el function like this:

function start_el( &$output, $item, $depth = 0, $args=array(), $current_object_id = 0 ) {
        $mi_rich_content = get_field('menu_item__rich_content', $current_object_id);
        if($mi_rich_content){
            $output .= "<li class='" .  implode(" ", $item->classes) . "'>";
            $output .= $mi_rich_content;
        }
    }

But it doesn't show any content at all if there is no content in the custom field. Doesn't $output contain some default content already ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.