WordPress.org

Ready to get started?Download WordPress

Forums

Loop Within Page Doubled Since Upgrade (2 posts)

  1. discoverKate
    Member
    Posted 8 years ago #

    I am having an interesting issue since upgrading from 1.5. I have pages with loop on them which all worked fine prior to the change. Now they are showing the information as I called it and a second time, following the original one, only the second time it is displaying the full content of each post on the page.

    One of my affected pages:
    http://www.discoverkate.com/kate/media/

    This same layout is working for my news archive page.
    http://www.discoverkate.com/Articles/categorias/general-kate-winslet-news/

    They all do this. Here's the code being used to call the loop within the page. We're using the Exec PHP plugin to use php code on the pages.


    <phpcode>
    < ?php query_posts('category_name=little-children&showposts=25'); ?>
    < ?php while (have_posts()) : the_post(); ?>
    < ? /*php if ( in_category('27')) : */?>
    < ?php the_date('F jS, Y',' <br><table align="center" width=480 cellpadding=0 cellspacing=1 valign="top"><tr><td class="index-headline">','</td></tr>') ?>
    <tr><td class="index-newsblock"><a>" rel="bookmark" title="Permanent Link to < ?php the_title(); ?>"><strong>< ?php the_title(); ?></strong></a> < ?php the_excerpt_reloaded(); ?> </td></tr>< ? /*php endif; */ endwhile; ?>
    </table> <div>�</div></phpcode>

    We've spent two hours on this so far and haven't yet found what is the problem. It is displaying the right category and right number of posts the correct way before doing the duplicate showing of the posts. We figured it's our code, but haven't found anyway to change the code that continues to work and doesn't show things twice.

    Any help appreciated. I've exhausted Google searching WordPress for answers and must have read The Loop page 3 times in addition to others. Any help, even just to point me to where this has been solved before would be of help.

    Btw, I should add, we're not using the rich text editor, I'm more of a see the code kind of a person. I've never prefered WYSIWYG editors.

  2. z
    Member
    Posted 8 years ago #

    In case someone has the same stuggle... What Discoverkate's was trying to do is call a second loop within a page using the exec-php plugin. Unfortunately what calling "query_posts" inside a page would do was reset the initial query used to display the post. So the same query would run once called from the template file (page.php) and once called from page content.

    To get around it we defined a new query as outlined here in the codex (example 2) and it worked like a charm :-)

Topic Closed

This topic has been closed to new replies.

About this Topic