我想将图像添加到我的子菜单的每个项目中。
目前,我已经在wordpress管理仪表板的每个菜单项中添加了一个自定义css类,并在css中添加了如下类:
.menu-fildutemps::before{
content: url(\'myurl\') !important; }
但它并不适用于所有项目,只适用于第一个项目。
有人能帮我吗?
Bellow,我的导航代码输入header.php
如有必要:
<nav class="navbar navbar-expand-lg navbar-light sticky-top">
<a class="navbar-brand small" href="<?php echo home_url(); ?>">
<!-- Image -->
<?php
$image = get_field(\'logo_izarra\', \'options\');
if( !empty($image) ): ?>
<img src="<?php echo $image[\'url\']; ?>" class="logo-izarra" alt="<?php echo $image[\'alt\']; ?>" />
<?php endif; ?>
<!-- Image -->
</a>
<button class="navbar-toggler custom-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navmobile" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav m-auto">
<?php
wp_nav_menu( array(
\'theme_location\' => \'top1\',
\'menu\' => \'top1\',
\'depth\' => 2, // 1 = no dropdowns, 2 = with dropdowns.
\'container\' => \'div\',
\'container_class\' => \'collapse navbar-collapse\',
\'container_id\' => \'navbarNav\',
\'menu_class\' => \'navbar-nav m-auto\',
\'fallback_cb\' => \'WP_Bootstrap_Navwalker::fallback\',
\'walker\' => new WP_Bootstrap_Navwalker(),
) );
?>
<a class="navbar-brand large" href="<?php echo home_url(); ?>">
<!-- Image -->
<?php
$image = get_field(\'logo_izarra\', \'options\');
if( !empty($image) ): ?>
<img src="<?php echo $image[\'url\']; ?>" class="logo-izarra" alt="<?php echo $image[\'alt\']; ?>" />
<?php endif; ?>
<!-- Image -->
</a>
<?php
wp_nav_menu( array(
\'theme_location\' => \'top2\',
\'menu\' => \'top2\',
\'depth\' => 2, // 1 = no dropdowns, 2 = with dropdowns.
\'container\' => \'div\',
\'container_class\' => \'collapse navbar-collapse\',
\'container_id\' => \'navbarNav\',
\'menu_class\' => \'navbar-nav m-auto\',
\'fallback_cb\' => \'WP_Bootstrap_Navwalker::fallback\',
\'walker\' => new WP_Bootstrap_Navwalker(),
) );
?>
</ul>
</div>
</nav>