This is my index.php (my homepage). It displays two loops. The first one displays the sticky posts and the second displays all of the posts. The <div id="primary"> that is located after the first loop is not appearing in my code or functions in my css. This is my code:

    <?php get_header(); ?>
<div id="top-homepage">
  <div id="featured">
  <!-- start sticky posts loop -->
      $sticky = new WP_Query( array(
        'showposts' => 6,
        'post__in'  => get_option('sticky_posts'),
        'caller_get_posts' => 1 ) 
    while ( $sticky->have_posts() ) : $sticky->the_post(); ?>
      <div class="featured-post">
        <a href="<?php the_permalink(); ?>">
          <?php the_post_thumbnail( 'featuredposts' ); ?>
          <h2 class="post-title">
            <?php echo get_the_title(); ?>
      </div><!-- end featured-post -->
    <?php endwhile; ?>
      </div><!-- end featured -->
      <div class="clear"></div>
  </div> <!-- end top homepage -- >

<div id="primary">

<!-- Start the Loop. -->
 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

<?php $countpost = $n++ ; ?>


  if ($countpost % 2 == 0) { ?>

  <div class="left-post">

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

      <!-- Display the Title as a link to the Post's permalink. -->

      <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

      Its even


<?php } else { ?>

<div class="right-post">

   <!-- Display the Title as a link to the Post's permalink. -->

 <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

 Its odd

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

<?php } ?>

 <!-- Stop The Loop (but note the "else:" - see next line). -->

 <?php endwhile; else: ?>

 <!-- The very first "if" tested to see if there were any Posts to -->
 <!-- display.  This "else" part tells what do if there weren't any. -->
 <p>Sorry, no posts matched your criteria.</p>

 <!-- REALLY stop The Loop. -->
 <?php endif; ?>

</div><!-- end primary-->

<?php get_footer(); ?>

Do anyone know a solution to this problem? Thanks in advance

2 Answers 2


<!-- end top homepage -- >

That is not a valid comment. I suspect that it has something to do with that. I really hate those typos. Hard to find.

  • OMG ! I have been searching since 3 days for the error, and its in the comment after all. Thanks man
    – Faisal
    Commented Nov 5, 2013 at 6:30
  • nice catch, you could actually see it in the way SE formats and colors the code but I couldn't figure what is the exact problem there. Commented Nov 5, 2013 at 6:37



after where the first WP_Query() ended (assuming, after the first endwhile;). It'll reset the first loop, and will give you a fresh loop (whether the default or a new one) after then.

» Codex: wp_reset_postdata()


I think the caller_get_posts is guilty. Because it's deprecated since WP v.3.1. Use ignore_sticky_posts instead.

ignore_sticky_posts (boolean) - ignore sticky posts or not (available with Version 3.1, replaced caller_get_posts parameter). Default value is 0 - don't ignore sticky posts. Note: ignore/exclude sticky posts being included at the beginning of posts returned, but the sticky post will still be returned in the natural order of that list of posts returned. (Source)

So, when you are using:

'caller_get_posts' => 1

you are actually saying:

'ignore_sticky_posts' => 1 //means IGNORE all the sticky posts

This WPSE thread can shed some light on this matter.

  • thanks for the reply. I tried it, but didn't seem to fix the error. I tried it in different places after the endwhile after the ending </div> nothing seems to work
    – Faisal
    Commented Nov 5, 2013 at 6:08
  • Ok. Though it won't fix your problem let it be. don't delete it, you need it (See WP_Query() usage). I'm digging it again for any further clue. Commented Nov 5, 2013 at 6:11
  • Ok. ferenyl pointed you to the right direction, but consider my one also side by side. It'll assist you get off from deprecated functions or values. (made a new edit) Commented Nov 5, 2013 at 6:32

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.