I made a Template page galerie.php and I wanted to show posts there.

Why isn't this working? It seems that posts only appear at home page for some reason.

The code is:

<?php while(have_posts()) : the_post() ?>
      <div id="owl-images" class="owl-carousel">
        <a href="<?php the_post_thumbnail() ?>" data-lightbox="image-1" data-title="<?php the_title() ?>">
          <div class="item">
            <div class="lazyOwl" style="background:url("<?php the_post_thumbnail() ?>") no-repeat center center;background-size:cover;height:300px;" alt=""></div>
      <?php endwhile; ?>
  • Have you set this as a page template for any page? I don't think while(have_posts()) : the_post() will work for custom page templates. Commented Nov 7, 2014 at 15:31
  • No I didn't because I have different pages with different contents.
    – azhpo
    Commented Nov 7, 2014 at 16:09
  • what posts would you like to show in this template? Commented Nov 7, 2014 at 16:39
  • Please read about WP_Query codex.wordpress.org/Class_Reference/WP_Query Commented Nov 7, 2014 at 21:04

2 Answers 2


1 Go to your WordPress Administration Panel. 2 edit home page 3 select template and update 4 go to setting-> reading , select home page


You can add after while loop reset & query_posts() same as: wp_reset_query(); query_posts('post_type=&showposts=10');

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.