the_content() alters post reference in the Loop
-
I’ve been having an odd issue with the_content() and the_excerpt() calls inside the Loop. As soon as either of these methods are called, any subsequent calls relating to the post (e.g. the_permalink(), edit_post_link()) all point to a single incorrect post.
Its as if these methods are altering the loop, and resetting the references to the first post in my only category (other than Uncategorized).
Has anyone encountered such behavior?
Loop code below, perhaps I’m doing something bizarre, as I’m new to WordPress. The symptom with the code below is that information in the “postmetadata” paragraph is correct, but the “Read More” link after the_excerpt() points to a completely different post (and always the same post).
<?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <p class="postmetadata"> <span class="metaEntry"><abbr class="published" title="<?php the_time(__('l, F jS, Y, g:i a', 'example')); ?>"><?php the_time(__('F j, Y', 'example')); ?></abbr></span><span class="delim">|</span> <span class="metaEntry"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?></span><span class="delim">|</span> <?php edit_post_link('Edit', '<span class="metaEntry">', '</span><span class="delim">|</span>'); ?> <span class="metaEntry"><?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></span> </p> <div class="entry"> <?php the_excerpt(); ?><a href="<?php the_permalink() ?>">Read more »</a> </div> </div> <?php endwhile; ?> <div class="navigation"> <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div> <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div> </div> <?php else : ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php get_search_form(); ?> <?php endif; ?>
The topic ‘the_content() alters post reference in the Loop’ is closed to new replies.