WordPress.org

Ready to get started?Download WordPress

Forums

Problem with Wp-query (5 posts)

  1. setnaps
    Member
    Posted 3 years ago #

    Hi. Good evening to all.
    I just upgrade to the last release of wordpress and something happened..

    I have the following code

    <div id="thumbnails">
    
             <?php
    		 $the_query = new WP_Query('category_name=' . '&showposts=200&cat=304&orderby=date&order=desc');
    		 $counter = 0;
    		 while ($the_query->have_posts()) : $the_query->the_post(); $do_not_duplicate = $post->ID;
    		 ?>
    
    		 	<div id="shop149clean">
    		 	<a href="<?php the_permalink() ?>" rel="bookmark"><?php if ( has_post_thumbnail() ) the_post_thumbnail( 'mini144-thumb' ); ?></a>
    		 	</div>
    
             <?php endwhile; ?>
    
         </div>

    the results of that you can see properly in this page

    But, when I want to create a page template, if I add the same code to the template, something very weird happens, which is that the last POST gets duplicated in the first position, while the first post dissappears...

    Check what I mean here

    Does anybody know why this happens????

    Thank you very much

  2. deepbevel
    Member
    Posted 3 years ago #

    that is odd, are you by chance running another loop on the same page?

  3. setnaps
    Member
    Posted 3 years ago #

    Hi Deepbevel..
    Thanks for answering...
    Well, I don't use any other loop in the template page. I didn't have this problem in the previous version of WordPress...something happened when I upgraded...

    so strange

  4. keesiemeijer
    moderator
    Posted 3 years ago #

    Why is 'category_name' in the query? try it with:

    $the_query = new WP_Query('posts_per_page=200&cat=304&orderby=date');

    try:
    - deactivating all plugins to see if this resolves the problem? If this works, re-activate the plugins one by one until you find the problematic plugin(s).

    - switching to the default theme to rule out any theme-specific problems.

  5. davidbritt76
    Member
    Posted 3 years ago #

    Placing the plugin call there will result in the correct pagination. You’ll get funky paging errors if it’s placed after the whole $wp_query variable swapping in the end.

    [link removed]

Topic Closed

This topic has been closed to new replies.

About this Topic