英雄下面的菜单,显示英雄单位上方的子菜单

时间:2018-04-20 19:33:18

标签: css wordpress navigation

我在网站上有一些我没有创建的条件代码(只是进行一些编辑)。导航菜单位于首页上的滑块下方。但是,当您将子菜单项目悬停在滑块上方时。以下是此页面的代码,我缺少什么?

$menu = wp_get_nav_menu_object( $menu_name );   
        $menu_items = wp_get_nav_menu_items($menu->term_id);

        $count = 0;
        foreach($menu_items AS $item):
            if($item->menu_item_parent==0) $count++;
        endforeach;

        $display = 'none';
        $i=0;
        foreach ( (array) $menu_items as $key => $menu_item ):
            if ($menu_item->menu_item_parent != 0 ) continue;
            $content = get_post_meta($menu_item->object_id, 
    'main_menu_hover_content', true);
            if(1):
                $subitems = array();
                foreach((array) $menu_items as $k => $subitem):
                    if($subitem->menu_item_parent==$menu_item->ID):
                        $subitems[] = $subitem;
                    endif;
                endforeach;
                if(count($subitems)): ?>
            <div class="overlay" id="overlay-<?=$menu_item->ID?>" style="display:<?=$display?>">
                <?php if(count($subitems)): ?>
                <div class="overlay-submenu clear">
                    <div class="in">
                    <span class="block" style="display: inline-block; width: <?= 
   ($i*20)?>%;"></span>
                    <?php foreach($subitems AS $subitem): ?>
                    <a href="<?=get_permalink($subitem->object_id)?>"><?=$subitem->title?></a>
                    <?php endforeach ?>
                    </div>
                </div>
                <?php endif ?>
             </div>
        <?php endif; endif; $display = 'none'; $i++;
        endforeach ?></div>
    </div>

        <div class="main-menu homepage-version"><?php 
        $args['walker'] = new Main_Menu_Walker; 
        $args['menu'] = $menu_name;

        $o = get_rootchild((object) $args);

         $children = wp_get_nav_menu_items( $o->menu, array('post_status'=>'publish') );
        $args['count'] = $count;
        wp_nav_menu($args) ?></div>

    <div class="sub-menu clearfix">
            <ul class="clearfix">
                <?php 
        $args['walker'] = new Submenu_Walker; 
        $args['menu'] = $menu_name;
        wp_nav_menu($args) ?>
            </ul>

0 个答案:

没有答案