Reputation: 3195
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 »</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 ?
Upvotes: 0
Views: 456
Reputation: 5007
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 »</p>'); ?>
</div>
</div>
<?php endwhile; endif; ?>
</div>
</div>
</div>
<div id="clear"> </div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
</div>
</body></html>
Upvotes: 2
Reputation: 17561
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();?>
Upvotes: 0