• Hello all,

    This is my first time working with wordpress and I have fairly minimal php knowledge. I’m building a webstie for my Brother’s church. I have wordpress integrated into the homepage and he is using it as a news feed. He wanted the ability to use the sticky feature and that is where I’m running into problems. When there is a sticky everything works fine, but when he doesn’t have a sticky the code pulls the first 10 posts for the sticky loop and then repeats them for the regular loop.

    This is the code I am using, any help would be greatly appreciated.

    <?php if (is_home() && !is_paged()) { ?>
                     <?php query_posts(array('cat'=> 2 ,'post__in'=>get_option('sticky_posts'))); ?>
                     <?php while (have_posts()) : the_post(); ?>
    
    				<h3> <?php the_date(); ?></h3>
    <hr />
    
    <div class="post" id="post-<?php the_ID(); ?>">
    	 <h3 class="storytitle"><?php the_title(); ?></h3>
    
    	<div class="storycontent">
    		<?php the_content(__('(more...)')); ?>
    	</div>
    
    </div>
    
    <?php endwhile; ?>
    <?php wp_reset_query(); ?>
    <?php } ?>
    
            <!--Regular Post excluding featured post -->
    				 <?php if (have_posts()) : ?>
    				 <?php query_posts(array('cat'=> 2 ,"post__not_in" =>get_option("sticky_posts"), 'paged' => get_query_var('paged'))); ?>
                     <?php while (have_posts()) : the_post(); ?>
    
    				<h3> <?php the_date(); ?></h3>
    <hr />
    
    <div class="post" id="post-<?php the_ID(); ?>">
    	 <h3 class="storytitle"><?php the_title(); ?></h3>
    
    	<div class="storycontent">
    		<?php the_content(__('(more...)')); ?>
    	</div>
    
    </div>
    
    <?php endwhile; ?>
    
    <hr />
    <div class="navigation">
     <div class="alignleft"><?php previous_posts_link('« Newer Entries') ?></div>
     <div class="alignright"><?php next_posts_link('Older Entries »','') ?></div>
     <?php endif; ?>
     <?php wp_reset_query(); ?>

    Thanks again.

  • The topic ‘Duplicating posts if there's no sticky’ is closed to new replies.