Support » Fixing WordPress » Where can I find the Loop?

  • I have completed a new install of WordPress and have chosen not to allow WordPress to create my home page. I want to embed the loop into an existing webpage.

    First major problem: Eh… where is the loop?

    I thought it was supposed to be in the index.php file created by WordPress. It’s not. I thought it might be in the homepage-index.php file created by WordPress. It’s not. I looked through many other *.php pages and still did not locate the loop.

    Interestingly enough, when I navigate my browser to the directory that WordPress resides in, the WordPress default page comes up all pretty and proper. When I click View -> Source on this page I can see all of the pertinent code, including the much sought after loop.

    Yet I still can’t find the file it is in. I’m at a loss and feeling very inferior at this point. I’m having this recurring dream that my name is Mr. Anderson and there’s a voice emanating from a bug in a line of code depicting a Campbell’s Soup can: “The Loop has you, Mr. Anderson”. Can/will someone help me locate this elusive “loop”? I want to find out how deep the nested while loop really goes…

    Thanks for reading my cry for help. ^_^

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello

    The “loop” is at in the file(s) index.php, archive.php, single.php, page.php and search.php

    The loop is all around you. Feel the loop.

    Ok sorry, erm seriously, the loop might look something like this in it’s basic form:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <div class="post">
    <h2><?php the_title() ?></h2>
    <?php the_date() ?>
    <?php the_content() ?>
    <?php endwhile; else: ?>
    Sorry, no posts could be found to match your criteria.
    <?php endif; ?>

    The line to look for is “<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>” which always marks the start of the loop.

    What theme are you using? The default theme should have the loop in the index file…

    For a more eloquent description of the loop, try

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Where can I find the Loop?’ is closed to new replies.