2013-04-27 129 views
0

你好我正在尝试添加分页到我用来显示自定义帖子类型的页面模板。我环顾了几个小时,但我还没有遇到明确的指示要遵循。页面模板上自定义帖子类型的分页

以下是我的页面模板php文件中的所有代码。如果有人能指出我正确的方向,将不胜感激。

我将不胜感激如何添加代码

<?php 
/* 
Template Name: Testimonials 
*/ 
?> 
<?php get_header(); ?> 
<div class="container_12">   

      <div id="content" class="grid_8">   
       <h1><?php the_title(); ?></h1> 
       <div id="testimonials">     
        <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $testimonials = new WP_Query(array('post_type' => 'testimonial', 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => '2', 'paged' => $paged)); ?> 
         <?php if (have_posts()) : ?> 
         <ul> 
          <?php while ($testimonials->have_posts()) : $testimonials->the_post(); ?> 
           <li> 
            <?php the_content(); ?> 
            <span><?php the_title(); ?></span>        
           </li>  
          <?php endwhile; ?> 
         </ul> 
         <?php else : ?> 
         <p><?php _e('No entry found.'); ?></p> 
        <?php endif; ?>  
        <div class="navigation"> 
        <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div> 
        <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div> 
        </div> 
       </div><!-- #testimonials -->     

      </div><!-- #content --> 

       <?php get_sidebar(); ?>      

     </div> 
<?php get_footer(); ?> 

我可以直接链接推荐/页/ 2 /访问第2页任何帮助。但在第1页上,导航没有出现。

第1页:

enter image description here

第2页:

enter image description here

回答

0

尝试使用query_posts()代替,看看是否能解决问题。

相关问题