Support » Everything else WordPress » index display certain categories

  • hi all,

    I’d like to display my default posts on the index page (which is my posts in English), and I put all of my Chinese posts in a category called “Chinese” and these posts are not inthe default category.

    The index page automatically displays all of the posts from every single category, and I tried to change the index.php codes so that the index page only displays default, however, it displays the default category as an archive and all of my blog links are gone because my index page has become an archive page.

    My question is, is it possible to only display the posts in the default cateory on the index page without having it to function as a category archive?

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Yes. You can add <?php query_posts(cat=-2); ?> before the loop in your index. The negative sign excludes, and the # is the ID of the category you want to exclude.

    Thread Starter iamsof

    (@iamsof)

    Parse error: parse error, unexpected ‘=’ in /home/sof/public_html/blog/index.php on line 3

    what is this problem?

    Dude here is how to do it..i found the solution

    Following this.it works
    hi guys found the solution
    its something like this

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <!– The following tests if the current post is in category 3. –>
    <!– If it is not, the code within The Loop is executed as normal. –>
    <!– If it is, nothing is done until the next post is processed. –>
    <?php if ( !(in_category(‘3’)) ) { ?>

    <div class=”post”>

    <h2>“><?php the_title(); ?></h2>

    <small><?php the_time(‘F jS, Y’); ?></small>

    <div class=”entry”>
    <?php the_content(); ?>
    </div>

    <p class=”postmetadata”>Posted in <?php the_category(‘, ‘); ?>
    </div> <!– closes the first div box –>

    <?php } ?> <!– Close the if statement. –>

    <?php endwhile; else: ?>
    Sorry, no posts matched your criteria.
    <?php endif; ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘index display certain categories’ is closed to new replies.