How to have a separate section for a particular category of posts in landing page?

It is possible, you have to create another loop for that particular category using WP_Query class. An example of a loop returning the range “Cats” 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() ) {
        $query->the_post();
        // do something
    }
} else {
    // no posts found
}

// Restore original Post Data
wp_reset_postdata();

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

Leave a Comment