Prevent Multiplying Posts
-
I am using the ‘Static Front Page’ plugin by Denis de Bernardy and I have created a page titled ‘Home’. That works fine.
Now I also want to show all posts that are in the news category below that. So I came up with the following page template.
<?php
/*
Template Name: New Home
*/
?>
<?php get_header(); ?>
<?php get_sidebar(); ?>
<div id="maincontent">
<!-- Home Template -->
<?php if (have_posts()) : while(have_posts()) : the_post(); ?><div class="post">
<h3><?php the_title(); ?></h3>
<div class="thecontent">
<?php the_content(''); ?>
</div>
</div><?php endwhile; endif; ?>
<?php query_posts('cat=1'); ?>
<?php if (have_posts()) : while(have_posts()) : the_post(); ?><?php $my_query = new WP_Query('category_name=news');
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID; ?>
<div class="post">
<h2><?php the_date(); ?></h2>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<div class="thecontent">
<?php the_excerpt(); ?>
</div>
</div>
<?php endwhile; ?><?php endwhile; endif; ?>
</div>
</div>
<?php get_footer(); ?>However, this only works for a single posts in the news category. When I add more than one post to the news category it multiplies the posting the category by the number of posts. For example if I have 3 news posts it displays the news category 3 times.
Weird huh?
Any tips or hints would be greatly received. Thanks
- The topic ‘Prevent Multiplying Posts’ is closed to new replies.