WordPress.org

Support

Support » How-To and Troubleshooting » Has my Loop gone “loopy”?

Has my Loop gone “loopy”?

  • I was in the process of installing a plug that required modifying The Loop. I went to the codex to make sure I knew where it was. It says:

    The loop starts here:
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    But mine says:

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php $custom_fields = get_post_custom(); //custom fields ?>

    I’m using Blix, and that’s the default code. Being the php novice that I am, what do the differences mean? Could it be affecting other things that I’m experiencing, like not being able to delete comments or pages?

Viewing 4 replies - 1 through 4 (of 4 total)
  • What this means if we have some posts, and while we work thru them, execute the function get post custom; once per post; and each time put the returned data in a variable (store) called $custom fields.

    Thanks. So I take it that changing this code is not uncommon? I ask only because I get the feeling The Loop is a special thing and should be handled with care (not sure where I got that, but thought it’s pretty important).

    This:

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

    is equivalent to The Loop as found in the installed themes and on Codex. The php tags enclosing the post functions (<?php ?>) are there to allow PHP to be included in an HTML document, and if you remove them, you’ll see the bare code is the same.

    Well the loop has its own mysteries. But like everything else in the end the urge to hack becomes irresistable. Backup your file and get stuck in. Codex is good.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Has my Loop gone “loopy”?’ is closed to new replies.
Skip to toolbar