我的菜单中有一个带有购物车数量的自举药。但是我不想在卡空的时候出药。如何在Walker菜单中使用If语句将其隐藏。
<?php
wp_nav_menu( array(
'theme_location' => 'primary',
'menu_id' => 'primary-menu',
'container' => 'div',
'container_class' => 'collapse navbar-collapse',
'container_id' => 'navbarsExampleDefault',
'menu_class' => 'navbar-nav ml-auto',
'fallback_cb' => '__return_false',
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s
<li class="nav-item language">
<a class="" href="'.wc_get_cart_url().'"><img class="icon-card" src="card-logo.svg"><span class="badge badge-pill badge-oranje">'.sprintf ( _n( '%d', '%d', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ).'</span></a>
<a class="" href=""><img class="icon-card" src="vlag-nl.svg"></a>
<a class="" href=""><img class="icon-card" src="vlag-uk.svg"></a>
</li>
</ul>',
'depth' => 3,
'walker' => new wp_bootstrap_navwalker()
) );
?>
</div>
和if语句
<?php
if ( WC()->cart->get_cart_contents_count() != 0 ) {
echo 'niet leeg';
}?>