Skip to main content
I rewrote some of the sentences in this question as the grammar not so much the spelling wasn't up to scratch.
Source Link

I am loosin a postIn my custom query, why ?

I have 10 post in category. whenevery time I do the requestquery for ALL the post in thatposts from a particular category: using WP_Query($arg).I get 9 post, all of them BUT the last created. Then a create a new one, there is 11 post now, then, i get and the category has 10 posts for example, last oneI seem to be missing... WHAT APPEND a post. So querying for 10 posts only returns 9, querying for 11 posts only returns 10 and so on. WP going crazy Does anyone know why I am always missing one post in my query results?

thisThis is the notworking code.. I am using that is not working. but someSome of my other test still docode tests have returned the same thingresults.

if($carouselOnOff){?>
<div id="carouselContainer">
<h2 id="sponsorsTitle"><?php echo get_cat_name( $carouselCategory ) ?></h2>
<ul id="carousel">
    <?php $showPostsInCategory = new WP_Query(); $showPostsInCategory->query('cat='. $carouselCategory .'&showposts='. $carouselNumber .'');
    if ($showPostsInCategory->have_posts()) : while ($showPostsInCategory->have_posts()) : $showPostsInCategory->the_post();?>
        <li>
            <?php $data = get_post_meta( $post->ID, 'key', true ); ?>
            <a href="<?php  if ($data[ 'custom_link' ]) { echo $data[ 'custom_link' ];} else { the_permalink(); } ?>">
                <?php the_post_thumbnail('sponsor', array('title' => "")); ?>
            </a>
        </li>
    <?php endwhile; endif; ?>
</ul><!--end carousel-->
</div><!--end carouselContainer-->
<?php } ?>

I am loosin a post, why ?

I have 10 post in category. when I do the request for ALL the post in that category: WP_Query($arg).I get 9 post, all of them BUT the last created. Then a create a new one, there is 11 post now, then, i get the 10, last one missing... WHAT APPEND.. WP going crazy ?

this is the notworking code... but some other test still do the same thing

if($carouselOnOff){?>
<div id="carouselContainer">
<h2 id="sponsorsTitle"><?php echo get_cat_name( $carouselCategory ) ?></h2>
<ul id="carousel">
    <?php $showPostsInCategory = new WP_Query(); $showPostsInCategory->query('cat='. $carouselCategory .'&showposts='. $carouselNumber .'');
    if ($showPostsInCategory->have_posts()) : while ($showPostsInCategory->have_posts()) : $showPostsInCategory->the_post();?>
        <li>
            <?php $data = get_post_meta( $post->ID, 'key', true ); ?>
            <a href="<?php  if ($data[ 'custom_link' ]) { echo $data[ 'custom_link' ];} else { the_permalink(); } ?>">
                <?php the_post_thumbnail('sponsor', array('title' => "")); ?>
            </a>
        </li>
    <?php endwhile; endif; ?>
</ul><!--end carousel-->
</div><!--end carouselContainer-->
<?php } ?>

In my custom query, every time I query for posts from a particular category using WP_Query() and the category has 10 posts for example, I seem to be missing a post. So querying for 10 posts only returns 9, querying for 11 posts only returns 10 and so on. Does anyone know why I am always missing one post in my query results?

This is the code I am using that is not working. Some of my other code tests have returned the same results.

if($carouselOnOff){?>
<div id="carouselContainer">
<h2 id="sponsorsTitle"><?php echo get_cat_name( $carouselCategory ) ?></h2>
<ul id="carousel">
    <?php $showPostsInCategory = new WP_Query(); $showPostsInCategory->query('cat='. $carouselCategory .'&showposts='. $carouselNumber .'');
    if ($showPostsInCategory->have_posts()) : while ($showPostsInCategory->have_posts()) : $showPostsInCategory->the_post();?>
        <li>
            <?php $data = get_post_meta( $post->ID, 'key', true ); ?>
            <a href="<?php  if ($data[ 'custom_link' ]) { echo $data[ 'custom_link' ];} else { the_permalink(); } ?>">
                <?php the_post_thumbnail('sponsor', array('title' => "")); ?>
            </a>
        </li>
    <?php endwhile; endif; ?>
</ul><!--end carousel-->
</div><!--end carouselContainer-->
<?php } ?>
added 927 characters in body
Source Link
menardmam
  • 912
  • 2
  • 18
  • 35

I am loosin a post, why ?

I have 10 post in category. when I do the request for ALL the post in that category: WP_Query($arg).I get 9 post, all of them BUT the last created. Then a create a new one, there is 11 post now, then, i get the 10, last one missing... WHAT APPEND.. WP going crazy ?

this is the notworking code... but some other test still do the same thing

if($carouselOnOff){?>
<div id="carouselContainer">
<h2 id="sponsorsTitle"><?php echo get_cat_name( $carouselCategory ) ?></h2>
<ul id="carousel">
    <?php $showPostsInCategory = new WP_Query(); $showPostsInCategory->query('cat='. $carouselCategory .'&showposts='. $carouselNumber .'');
    if ($showPostsInCategory->have_posts()) : while ($showPostsInCategory->have_posts()) : $showPostsInCategory->the_post();?>
        <li>
            <?php $data = get_post_meta( $post->ID, 'key', true ); ?>
            <a href="<?php  if ($data[ 'custom_link' ]) { echo $data[ 'custom_link' ];} else { the_permalink(); } ?>">
                <?php the_post_thumbnail('sponsor', array('title' => "")); ?>
            </a>
        </li>
    <?php endwhile; endif; ?>
</ul><!--end carousel-->
</div><!--end carouselContainer-->
<?php } ?>

I am loosin a post, why ?

I have 10 post in category. when I do the request for ALL the post in that category: WP_Query($arg).I get 9 post, all of them BUT the last created. Then a create a new one, there is 11 post now, then, i get the 10, last one missing... WHAT APPEND.. WP going crazy ?

I am loosin a post, why ?

I have 10 post in category. when I do the request for ALL the post in that category: WP_Query($arg).I get 9 post, all of them BUT the last created. Then a create a new one, there is 11 post now, then, i get the 10, last one missing... WHAT APPEND.. WP going crazy ?

this is the notworking code... but some other test still do the same thing

if($carouselOnOff){?>
<div id="carouselContainer">
<h2 id="sponsorsTitle"><?php echo get_cat_name( $carouselCategory ) ?></h2>
<ul id="carousel">
    <?php $showPostsInCategory = new WP_Query(); $showPostsInCategory->query('cat='. $carouselCategory .'&showposts='. $carouselNumber .'');
    if ($showPostsInCategory->have_posts()) : while ($showPostsInCategory->have_posts()) : $showPostsInCategory->the_post();?>
        <li>
            <?php $data = get_post_meta( $post->ID, 'key', true ); ?>
            <a href="<?php  if ($data[ 'custom_link' ]) { echo $data[ 'custom_link' ];} else { the_permalink(); } ?>">
                <?php the_post_thumbnail('sponsor', array('title' => "")); ?>
            </a>
        </li>
    <?php endwhile; endif; ?>
</ul><!--end carousel-->
</div><!--end carouselContainer-->
<?php } ?>
Source Link
menardmam
  • 912
  • 2
  • 18
  • 35

Why always one post missing

I am loosin a post, why ?

I have 10 post in category. when I do the request for ALL the post in that category: WP_Query($arg).I get 9 post, all of them BUT the last created. Then a create a new one, there is 11 post now, then, i get the 10, last one missing... WHAT APPEND.. WP going crazy ?