• Hi everyone,

    Just like the title says, I’d like to display all my posts from a custom-post-type ordered by categories.

    Exemple:

    Category 1
    Post 1
    Post 2
    ….
    Category 2
    Post 1
    ….

    For the moment I only display all the posts:

    <?php
             $args = array(
                   'post_type' => 'fournisseur' ,
                   'posts_per_page' => '-1');
    
             $category_posts = new WP_Query($args);
    
             if($category_posts->have_posts()) :
                while($category_posts->have_posts()) :
                   $category_posts->the_post();
    ?>
          <h3><?php the_title() ?></h3>
          <div class='post-content'>
             <?php the_content() ?>
          </div>
          <?php
             endwhile;
             else:
          ?>
          <?php
             endif;
          ?>

    I’m new to wordpress and php functions so please be nice to me ??

    thx.

  • The topic ‘Display list of posts orderby Categories’ is closed to new replies.