Before I call the_excerpt(), the_permalink() displays the correct thing. Afterwards, it does not...

            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 &raquo;</a></div>
            <?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()"

  • 1
    does the theme use any filter function on the excerpt or related template tags?
    – Michael
    Commented Jun 28, 2011 at 18:31
  • Two. One to change the length of the excerpt to just be "50". One to change the ellipses to just "..." instead of "[...]". They are each, like, 3 lines of code, so nothing that would cause what is happening (that I can tell).
    – cmcculloh
    Commented Jun 29, 2011 at 3:02
  • take a look on function reference
    – Ramkumar M
    Commented Jun 29, 2011 at 4:32
  • What about it? The two filter functions I stated as having are basically mentioned in the function reference, btw, so it can't be those...
    – cmcculloh
    Commented Jun 30, 2011 at 2:28

1 Answer 1


I had installed the "Facebook Comments for WordPress" plugin. This plugin attaches a filter to the_content();. The filter contains the line wp_reset_query();. Commenting this out fixes the problem (this is sub-optimal though, because, now the client will be unable to update the plugin).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.