I’m new to worpdress. I’ve only just gotten this query to work with a custom post type I made but now I’ve run into another issue when it came to following the design specifications of the website.

This page is supposed to display the products under their respective Categories. The loop I have made only shows each product but does not display the category of it for all of them.

I was intending for it to look something like this:

CAT

  • ITEM
  • ITEM
  • ITEM
  • ITEM

CAT

  • ITEM
  • ITEM
  • ITEM
  • ITEM

But instead I’m only getting this:

  • ITEM
  • ITEM
  • ITEM

I’m not looking for something like this:

  • ITEM, cat under title
  • ITEM, cat under title
  • ITEM, cat under title

      <?php
    $args = array (
      'post_type' => 'products',
      'posts_per_page' => 10,
    );
    
    $loop = new WP_query( $args );
    
    if($loop->have_posts()):
      while($loop->have_posts()): $loop->the_post(); ?>
        <div class="post-loop-single">
          <div class="thumbnail-img"><a href="<?php the_permalink(); ?>"><span><?php the_post_thumbnail('post-thumb'); ?> </span></a></div>
          <div class="post-loop-text">
            <div class="post-loop-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
          </div>
      </div>
      <?php endwhile;
    endif;
    

    ?>

Read more here: WordPress Loop to display Category and posts under


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: