skip to Main Content

I want to display all products that are in specific category and brand. For example I have category boiler and brand Ariston. Is there any way to display only Ariston’s boilers?

2

Answers


  1. You can do this:

    $loop = new WP_Query(
                array(
                    'post_type' => 'product',
                    'posts_per_page' => -1,
                    'orderby' => 'date',
                    'order'   => 'DESC',
                    'category_name' => 'Ariston'
                )
            );
    

    Then, you can read the loop:

     <?php while ($loop->have_posts()) : $loop->the_post(); ?>
                
             <div>
                 <?php echo get_the_title(); ?> - <?php echo get_the_content(); ?>
             </div>
    
             <?php endwhile; ?>
    

    And then, you can use the result in the way you want.

    I hope I have made myself understand.

    Login or Signup to reply.
  2. You could use the [products] if your brand is under the category as well then follow the code below:

    [products category="Ariston,boiler" cat_operator="AND"]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search