0

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??

3
  • could you post more the code? (the loop, etc) - to give it some context? Feb 7, 2012 at 18:42
  • @StephenHarris I updated the question Feb 7, 2012 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, 2012 at 19:22

2 Answers 2

1

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' )));
0
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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