Support » Plugins » Hacks » Embed Category Search Into Page Loop issues

  • Greetings WP community,
    I’ve been playing with WP for a while now and I’m trying to create an ‘events’ page that will post wordpress posts from ‘cat=4’ or the events category. It is posting fine except for the issue that it is looping the posts over and over again infinitely. Is there a way I can loop this so it shows all category posts but doesn’t repeat them? Thanks for all the help everyone!

    <?php if (have_posts()) :  ?>
                        <?php while (have_posts()) : the_post(); ?>
                            <article id="post-<?php the_ID(); ?>" <?php post_class('clearfix post'); ?> role="article">
                                    <h2 class="line"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
                                </header> <!-- end article header -->
                                <section class="post_content clearfix" itemprop="articleBody">
    while (have_posts()) : the_post();

Viewing 1 replies (of 1 total)
  • Moderator bcworkz


    You appear to be running nested loops and are not using wp_reset_query() after using query_posts().

    You should either endwhile the main loop before using query_posts() and a second loop, or use query_posts() before the main loop (without the second loop) if you do not want the normal loop to run at all.

    And don’t forget to reset after using query_posts().

Viewing 1 replies (of 1 total)
  • The topic ‘Embed Category Search Into Page Loop issues’ is closed to new replies.