Adding The Loop Above the Header Makes Every Post the Same
-
Greetings,
Amateur Web developer here so please forgive me if I get the vocabulary wrong.
I’m trying to add a “query_posts” function above the header on my site to call some custom fields for a particular category. Here’s the code:
<?php query_posts("showposts=1&category_name=Headline"); ?> <?php while (have_posts()) : the_post(); ?> <?php $values = get_post_custom_values("Headline"); if (isset($values[0])) { ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><span class="headline"> <?php $values = get_post_custom_values("Headline"); echo $values[0]; ?></span></a> <?php } ?> <?php endwhile; ?> <br /> <?php query_posts("showposts=1&offset=1&category_name=Headline"); ?> <?php while (have_posts()) : the_post(); ?> <?php $values = get_post_custom_values("Headline"); if (isset($values[0])) { ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><span class="headline2"> <?php $values = get_post_custom_values("Headline"); echo $values[0]; ?></span></a> <?php } ?> <?php endwhile; ?>
In this case, I’m trying to call the value for “Headline” for the first two posts in the “Headline” category. The information is called and displayed correctly. However, all of the permalinks on the page now point to the last post in the “Headline” category.
What am I doing wrong?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Adding The Loop Above the Header Makes Every Post the Same’ is closed to new replies.