2010-01-27 195 views
0

我已经创建了一个名为“产品”WordPress的自定义页面模板

<?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> 

但它不显示我的帖子,我究竟做错了一个自定义页面?

回答

2

此代码doenst显示您的文章就像一个博客页面,这个代码显示的页面“产品”仅内容,以显示你所有的帖子,您必须使用其他代码:

<?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> 
0

对于一个标准的WordPress循环,这<?php endwhile; endif; ?>应该

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

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

<?php endif; ?> 

<?php get_sidebar(); ?> 
<?php get_footer();?> 
+0

注意到会发生!它不会显示任何帖子! – datisdesign 2010-01-27 17:19:44

相关问题