• Hello,
    First of all..Happy new year to all!.I want to know if there is any method to show only posts for selected categories in the main page.. E.g. Say you have a techy category which really is not the main focus if you take the website in whole and posts related to that category should not be posted on the main page. How do deal with this? currently every post made by any category is displayed!

Viewing 1 replies (of 1 total)
  • Thread Starter janantha

    (@janantha)

    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 1 replies (of 1 total)
  • The topic ‘Selective category posts on the index page?’ is closed to new replies.