• Resolved guruFTW

    (@guruftw)


    Is there a way to display posts from a category on the top of the site, and to display other categories posts completely separated from the “Main one”?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hristo Pandjarov

    (@hristo-sg)

    SiteGround Representative

    Hello,

    To do this, you need to have separate loops and to reset the wp_query after the first one.

    Generally, you need a piece of code like this:

    <?php
    query_posts( 'cat=1,2,3' );
    while (have_posts()) : the_post(); ?>
    	<h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
    	<div class="content"><?php the_content(''); ?></div>
    <?php endwhile;
    wp_reset_query();
    ?>

    First, with query_posts, you chose the categories of the shown posts. Enter their IDs. Then you cycle through all the posts in those categories and show their title and content. Finally, with wp_reset_query you reset the query. This means that after this code you can display the active post ??

    Thread Starter guruFTW

    (@guruftw)

    Works, thanks a lot!
    Marking as resolved.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Showing other categories posts separated from eachother’ is closed to new replies.