• Hi,

    I have a home.php template that creates a new WP_Query object then shows 2 posts from the blog. After the <?php endwhile; ?> I have two query_posts() functions, one filtering for posts in cat=10 the other for posts in cat=-10 (ie. all other categories) that both include the same mini-index template.

    The second one isn’t working, it lists nothing. The code is:
    <h3>Events</h3>
    <?php rewind_posts(); ?>
    <?php query_posts('cat=10'); //gets all posts from category 10
    load_template( TEMPLATEPATH . '/mini-index.php'); //loads home page category links
    ?>
    <h3>Diary</h3>
    <?php query_posts('cat=-10'); //gets all posts from categories other than 10
    load_template( TEMPLATEPATH . '/mini-index.php'); //loads home page category links
    ?>

    TIA

Viewing 1 replies (of 1 total)
  • Query_posts can be used to control which posts show up in The Loop….

    …Place a call to query_posts() in one of your Template files before The Loop begins….

    Above from http://codex.wordpress.org/Template_Tags/query_posts

    Note: I didn’t see a question in your post, so I’m guessing here, but it looks like you’re expecting query_posts to return posts and it won’t. It just changes the query used in the following Loop.

Viewing 1 replies (of 1 total)
  • The topic ‘query_posts() problems’ is closed to new replies.