Before I call the_excerpt(), the_permalink() displays the correct thing. Afterwards, it does not…
<?php
global $query_string;
//strip out the "pagename=blog" so that the query will grab all of the posts instead of the content of the blog page
$query_string = preg_replace("/pagename=[a-zA-Z0-9]*/", "", $query_string);
query_posts( $query_string . "posts_per_page=3" );
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li class="post-listing">
<div class="no-col">
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<p class="meta">Posted on <?php print get_the_date(); ?> by <?php the_author(); ?> in <?php the_category(', ') ?></p>
<!--
<?php the_permalink(); ?>
-->
<?php the_excerpt(); ?>
<!--
<?php the_permalink(); ?>
-->
<p class="meta"><?php the_tags('') ?></p>
<div class="navigation"><a class="alignright" href="<?php the_permalink(); ?>">READ MORE »</a></div>
</div>
</li>
<?php endwhile; else: ?>
<li><?php _e('Sorry, no posts matched your criteria.'); ?></li>
<?php endif; ?>
I have a page called “blog.php” that I have defined as a Template named “blog” that people can apply to a page they create (so that they can have a blog listing page, I know there is probably a better way, but this is the solution that was gone with for various reasons).
It was working just fine, but now (a month after I wrote it) it suddenly stopped working. I have narrowed the problem (I think) down to the the_excerpt() call. The permalink displays fine before that, but afterwards craps out and instead displays the permalink for the blog.php page… I think that the_excerpt() is throwing everything completely out of “The Loop” and then the current post it sees just becomes the page that uses the blog.php template (it spits the contents of that page out and then stops as if that page were the last post in The Loop).
This also happens if I replace “the_excerpt()” with “the_content()” or “get_the_excerpt()”
I had installed the “Facebook Comments for WordPress” plugin. This plugin attaches a filter to
the_content();
. The filter contains the linewp_reset_query();
. Commenting this out fixes the problem (this is sub-optimal though, because, now the client will be unable to update the plugin).