I wish to have a different section for a certain category of posts displayed in the landing page of my WordPress website, while posts of various other categories display in an other section.

Is this possible in WordPress?


It is possible, you will need to create another loop for that special category using WP_Query class. An example of a loop returning the "cats" category would be:

// WP_Query arguments
$args = array (
    'category_name'          => 'cats',

// The Query
$query = new WP_Query( $args );

// The Loop
if ( $query->have_posts() ) {
    while ( $query->have_posts() ) {
        // do something
} else {
    // no posts found

// Restore original Post Data

Depending on the number of sections on your landing page, you will have multiple loops, but do not forget to reset each loop on the page.

  • wow I'm not that into programming or coding. Thanks though. Where do I insert this or a similar snippet? :) – Todo Pertin Oct 11 '15 at 9:56
  • probably in index.php? – Todo Pertin Oct 11 '15 at 10:00
  • It goes into template your landing page uses. If not using any custom Page template, then index.php is likely the template you are using for the home (landing) page. – Bruno Kos Oct 11 '15 at 21:39

yes this is definitely possible. You basically you need to do is combine multiple loops with custom loop queries, more info can be found here: The Loop

 <?php $query = new WP_Query( 'cat=CATEGORY ID YOU WANT TO DISPLAY HERE' ); ?>
 <?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>


 <?php endwhile; endif; ?>

 <?php rewind_posts(); ?>

<?php $query = new WP_Query( 'cat=2ND CATEGORY ID YOU WANT TO DISPLAY HERE' ); ?>
<?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>


 <?php endwhile; endif; ?>

Remember the rewind_posts() method to get this to work properly

  • can't thank you enough. thanks. I will try to work it out now, myself. – Todo Pertin Oct 11 '15 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.