为什么下拉菜单在WordPress中不起作用?

时间:2019-10-14 07:01:49

标签: wordpress

我已经在我的帐户菜单下设置了 4个子菜单。这是图片:

enter image description here

但是在前端,当我将鼠标悬停在我的帐户页面上时,看不到子菜单。

enter image description here

我正在使用以下代码显示完整菜单:

<?php       
if(is_user_logged_in()){
    $theme_location  = 'after_login_menu';
} else {
    $theme_location = 'header_menu';
}
$args = array(
    'container'       => 'div',
    'container_class' => 'navbar-collapse collapse',
    'container_id'    => 'th_navbar_toggle',
    'menu_class'      => 'navbar-nav ml-auto',
    'menu_id'         => '',
    'echo'            => true,
    'before'          => '',
    'after'           => '',
    'link_before'     => '',
    'link_after'      => '',
    'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
    'item_spacing'    => 'preserve',                                
    'walker'          => new wp_bootstrap_navwalker(),
    'theme_location'  => $theme_location,
    'menu'            => $theme_location,                                
    'depth'           => 5,
);
wp_nav_menu($args);
?>

我有什么想念的吗?

2 个答案:

答案 0 :(得分:2)

我的帐户的所有“子菜单”都位于

<ul class="dropdown-menu">

并从CSS隐藏

您可以添加

ul.dropdown-menu {display:block!important; }

并检查是否显示“我的帐户”的所有子菜单。

如果是,那么您可以

ul.dropdown-menu

将其悬停显示

让我知道它是否有效

答案 1 :(得分:1)

我已经检查过了。 请检查-> http://prntscr.com/pixrgl显示未添加任何内容。

添加课程 添加此CSS并检查它。

检查ul的类名称ID(ul#menu-main-menu,ul.dropdown-menu)

ul#menu-main-menu li:hover ul.dropdown-menu {
    display: block;
    position: absolute;
    top: 100%;
    left: 0;
    float: left;
    min-width: 160px;
    padding: 5px 0;
    margin: 0px 0 0;
    font-size: 14px;
    text-align: left;
    list-style: none;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ccc;
    border: 1px solid rgba(0,0,0,.15);
    border-radius: 4px;
    -webkit-box-shadow: 0 6px 12px rgba(0,0,0,.175);
    box-shadow: 0 6px 12px rgba(0,0,0,.175);
}
ul.dropdown-menu {
    display: none;
}
ul.dropdown-menu>li>a {
    display: block;
    padding: 3px 20px;
    clear: both;
    font-weight: 400;
    line-height: 1.42857143;
    color: #333;
    white-space: nowrap;
}