Как при нажатии на кнопку выводить записи произвольного типа определенной категории?

Есть товары, созданные произвольным типом записей. Они выводятся на странице каталога и нужно сделать вывод по производителю, категории, цене. А также сортировку по цене и популярности. Заранее спасибо!

введите сюда описание изображения

Вот цикл вывода записей

<?php if(have_posts()) : while(have_posts()) : the_post(); ?>

                <?php // параметры по умолчанию
                    $posts = get_posts( array(
                        'numberposts' => 0,
                        'post_type'   => 'goods',
                        'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
                    ) );

                    foreach( $posts as $post ){ setup_postdata($post); ?>
                        <div class="goods__item">
              
                          <div class="product__header goods__name"><?php the_field('goods_name') ?></div>
                          <ul class="product__stars">
                            
                          </ul>

                          <img class="goods__item-stars" src="<?php echo get_template_directory_uri() ?>/img/stars/stars<?php the_field('goods__stars') ?>.png" alt="">

                          <div class="product__rank goods__rank"><?php the_field('goods_rating') ?></div>

                          <?php the_post_thumbnail('', 'class=goods__img') ?>
                          <div class="goods__container-right">
                            <div class="product__discount goods__discount"><?php the_field('goods_price') ?> руб</div>
                            <div class="product__count goods__count"><?php the_field('goods_discount') ?> руб</div>
                          </div>

                          <div class="product__buttons goods__buttons">
                            <button class="button-show product-button">
                              <img class="hits-buttons-img" src="<?php echo get_template_directory_uri() ?>/img/cart 1.png" alt="">
                              <a href="<?php the_permalink() ?>" class="button-link">Купить быстро</a>
                            </button>
                            <button class="button-show product-button product-button_transparent">
                              <img class="hits-buttons-img" src="<?php echo get_template_directory_uri() ?>/img/cart 2.png" alt="">
                              <a href="<?php the_permalink() ?>" class="button-link">Купить</a>
                            </button>
                          </div>

                          <div class="goods__desc">
                            <div class="goods__availability"><?php the_field('goods_availability') ?></div>
                            <div class="goods__delivery">Доставка - <?php the_field('goods_delivery') ?> дня</div>
                          </div>
                          
                        </div> <!-- goods__item -->
                    <?php }

                wp_reset_postdata(); // сброс ?>

            <?php endwhile; ?>
            <?php endif; ?>


Ответы (0 шт):