• HI,

    I have the Categoried like cat1,cat2,cat3,cat4
    Now, I want to create a template or page which shows firstly all posts from cat2 and then after all posts from cat3.

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Create one loop… then create a secondary loop.

    <?php
    $cat2 = new WP_Query('category_name=cat2');
    
    while ($cat2->have_posts()) : $cat2->the_post();
      // Do your loop stuff for category two here...
      the_title();
      the_content();
    endwhile;
    ?>
    <?php
    $cat3 = new WP_Query('category_name=cat3');
    
    while ($cat3->have_posts()) : $cat3->the_post();
      // Do your loop stuff for category three here...
      the_title();
      the_content();
    endwhile;
    ?>
    Thread Starter baljit12

    (@baljit12)

    Thanks. Buddy…
    I will try this now.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Order posts by category’ is closed to new replies.