WordPress.org

Ready to get started?Download WordPress

Forums

How to show post form a single Category using query_posts (3 posts)

  1. davidetaibi
    Member
    Posted 6 years ago #

    I'm trying to show only the category 4 in the first page. (http://www.taibi.it)

    I've used the query_posts method but it still not works... it shows always the recent post

    <?php
    query_posts('cat=4');
    if ($posts) : foreach ($posts as $post) : start_wp(); ?>

    <div class="post">
    <?php require('post.php'); ?>
    </div>
    <?php endforeach; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>

    Could anyone help me?

    Greats

    Davide

  2. MichaelH
    Member
    Posted 6 years ago #

    Might look at the Codex article The Loop, and the section on how to exclude posts from a certain category for ideas.

  3. MichaelH
    Member
    Posted 6 years ago #

    I should also note you could use a plugin such as Category Visibility.

Topic Closed

This topic has been closed to new replies.

About this Topic