• hi,

    I am trying to build an editable footer by calling all posts with the category name Footer. I am having problems though as I eiteher get an infinate loop or an error complaining of an unexpected endif or endwhile the code I have at the moment is

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php query_posts(‘category_name=Footer&showposts=1’); ?>
    <div <?php post_class() ?> id=”post-<?php the_ID(); ?>”>
    <h2>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></h2>
    <p><?php the_time(‘F jS, Y’) ?> <!– by <?php the_author() ?> –></p>
    <?php the_content(‘Read the rest of this entry »’); ?>
    <p><?php the_tags(‘Tags: ‘, ‘, ‘, ‘
    ‘); ?> Posted in <?php the_category(‘, ‘) ?> | <?php edit_post_link(‘Edit’, ”, ‘ | ‘); ?> <?php comments_popup_link(‘No Comments »’, ‘1 Comment »’, ‘% Comments »’); ?></p>
    </div>

    <?php endwhile; else: ?>
    <p><?php _e(‘Sorry, no posts matched your criteria.’); ?></p>
    <?php endif; ?>

    Can someone have a look through and see where I am going wrong. Much apreciated.

    Rachel

Viewing 2 replies - 1 through 2 (of 2 total)
  • i think the reason is the sequence of these first lines:
    normally the query_posts() would be before the while(have_posts()); or even before the if(have_posts());

    if you don’t have an extreme good reason to keep this sequence, you could try to rearrange these lines to:

    <?php query_posts('category_name=Footer&showposts=1'); ?>
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    Thread Starter rachelreveley

    (@rachelreveley)

    Thanks alchymyth you are a hero

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Ending the loop’ is closed to new replies.