Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Can someone please help me alter my coding to eliminate my problem? I am using this line before the loop:

<?php query_posts('cat=3&showposts='.get_option('posts_per_page')); ?>

for context:

<?php get_header(); ?>

<div id="page-wrap">

    <div id="content">

        <div class="post-wrap">

        <?php query_posts('cat=9&showposts='.get_option('posts_per_page')); ?>

        <?php if (have_posts()) : ?>

            <?php while (have_posts()) : the_post(); ?>

                <div <?php post_class('post') ?> id="post-<?php the_ID(); ?>">
                    <h2 class="blog-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
                        <small></small>

                    <div class="entry">
                        <?php the_content('Read the rest of this entry &raquo;'); ?>
                    </div>      

                    <p class="postmetadata">Posted <?php the_time('M j Y') ?></p>   
                </div>


            <?php endwhile; ?>

            <div class="navigation">
                <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
                <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
            </div>

            <div class="clear"></div>

        <?php else : ?>

            <h2 class="center">Not Found</h2>
            <p class="center">Sorry, but you are looking for something that isn't here.</p>
            <?php get_search_form(); ?>

        <?php endif; ?>

        </div><!-- .post-wrap -->

    </div><!-- #content -->

I believe this is what is causing my latest post to show up twice. Is there supposed to be something else along with this line??

share|improve this question
    
could you post more the code? (the loop, etc) - to give it some context? –  Stephen Harris Feb 7 '12 at 18:42
    
@StephenHarris I updated the question –  Eratosthenes Feb 7 '12 at 18:57
    
As of version 2.1 of WP, showposts is deprecated in favor of posts_per_page. However I don't know if that's the problem. –  Shane Feb 7 '12 at 19:22
add comment

2 Answers

up vote 1 down vote accepted

Try replacing your code with the following:

$wp_query = new WP_Query();
$wp_query->query( array( 'cat' => '9', 'posts_per_page' => get_option( 'posts_per_page' )));
share|improve this answer
    
thanks so much! –  Eratosthenes Feb 10 '12 at 16:51
add comment

replace

<?php query_posts('cat=9&showposts='.get_option('posts_per_page')); ?>

with

<?php query_posts('cat=9&posts_per_page='.get_option('posts_per_page')); ?>

after the while loop (just after endwhile) insert

wp_reset_query();

if it does not solve the problem then try getting value of get_option('posts_per_page') to see if it is not the culprit.

If nothing solves the problem, then try @fxfutures answer.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.