views:

42

answers:

2

I have created a custom page named 'products'

<?php
/*
 Template Name: Products
*/
?>
<?php get_header(); ?>

<div id="products_content">
  <div id="products_page_header">
    <div id="products_page" title="محصولات">
      <?php if (have_posts()) : while (have_posts()) : the_post();?>
      <div class="post">
        <h2 id="post-<?php the_ID(); ?>">
          <?php the_title();?>
        </h2>
        <div class="entrytext">
          <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
        </div>
      </div>
      <?php endwhile; endif; ?>
    </div>
  </div>
</div>
<div id="clear"> </div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
</div>
</body></html>

but it doesnt show my posts, what am I doing wrong ?

A: 

For a standard wordpress loop, this <?php endwhile; endif; ?> should be

<?php endwhile; ?>
<?php else : ?>

(optional: Sorry, but you are looking for something that isn't here.)

<?php endif; ?>

<?php get_sidebar(); ?>
<?php get_footer();?>
songdogtech
noting happens ! it wont show any post !
Datis
+2  A: 

This Code doenst shows your Posts like an Blog Page, this Code shows only the Content of the Page "Products", to show all your Posts, you must use another code:

<?php
/*
 Template Name: Products
*/
?>
<?php get_header(); ?>

<div id="products_content">
  <div id="products_page_header">
    <div id="products_page" title="محصولات">
      <?php $query = new WP_Query('showposts=10'.'&paged='.$paged); ?>
            <?php if ($query->have_posts()) : ?>
        <?php while ($query->have_posts()) : $query->the_post(); ?>
      <div class="post">
        <h2 id="post-<?php the_ID(); ?>">
          <?php the_title();?>
        </h2>
        <div class="entrytext">
          <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
        </div>
      </div>
      <?php endwhile; endif; ?>
    </div>
  </div>
</div>
<div id="clear"> </div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
</div>
</body></html>
ahmet2106