Viewing 1 replies (of 1 total)
  • Plugin Author wizzud

    (@wizzud)

    CMW’s container option is intended to take a tag, because that’s what wp_nav_menu() handles.

    The tags that wp_nav_menu() accepts can be modified from the defaults (“div” or “nav”) by using a filter – “wp_nav_menu_container_allowedtags” (ref: wp_nav_menu() in wp-includes/nav-menu-template.php) – but that filter receives nothing that lets you know whether wp_nav_menu() is processing a CMW menu or some other menu (should you need to be able distinguish).

    An alternative might be to hook into wp_nav_menu()‘s “wp_nav_menu” filter. For example…

    add_filter( 'wp_nav_menu', 'my_cmw_nav_menu_filter', 10, 2 );
    function my_cmw_nav_menu_filter( $nav_menu, $args ){
        if( !empty( $args->_custom_menu_wizard )
                && !empty( $args->_custom_menu_wizard['container'] ) ){
            $nav_menu = preg_replace(
                '/^<(' . $args->_custom_menu_wizard['container'] . ')/',
                '<$1 itemscope="itemscope"',
                $nav_menu
                );
        }
        return $nav_menu;
    }

Viewing 1 replies (of 1 total)

The topic ‘Schema Markup’ is closed to new replies.