P
P
Pavel2019-12-05 11:18:09
WordPress
Pavel, 2019-12-05 11:18:09

How to find out the number of products in the filter by attribute?

Hello. I'm making a menu of categories, in which a filter by attribute should immediately be displayed. In principle, I made it static, because. everything is known in advance. It turned out something like:

$menu_list .= '<li class="sidebar-menu__item"><a href="' . $menu_item->url . '" class="sidebar-menu__link">' . $menu_item->title . '</a>
        <ul class="sidebar-atr-menu">
        <li class="atr-menu one-star">
        <a href="' .$menu_item->url .'?filter_slojnost=1">Лёгкие</a>
        </li>
        <li class="atr-menu two-star">
        <a href="' .$menu_item->url .'?filter_slojnost=2">Средние</a>	
        </li>
        <li class="atr-menu three-star">
            <a href="' .$menu_item->url .'?filter_slojnost=3">Сложные</a>	
        </li>										
     </ul>
     </li>

That is, the filter of the current category by the "complexity" attribute, the question is how to hide the item if there are no products when filtering.
something like
if ( count > 0 ) {

}

Can anyone tell me how to "dig out" the number of products with the filtering I need?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question