为什么我的wordpress主题中的分页没有显示(wp-paginate插件)

时间:2018-07-02 13:24:42

标签: javascript php html wordpress pagination

我在wordpress中使用了重新思考主题,并使用了wp-paginate插件

在arcive.php,category.php和index.php中的

分页很好 但是为什么在page.php中没有运行?

,我创建了自己的模板,显示所有帖子 posting.php

<?php

/*
Template Name: posting
*/

get_header();
?>

 <div class="full-content">
    <div class="grid_17 alpha">
        <div class="content_bar">            
            <div class="feature_content">
                
                <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                <?php
                 $count_posts = wp_count_posts();
                 $published_posts = $count_posts->publish;
                 $myposts = get_posts(array('posts_per_page'=>3)); ;
                foreach($myposts as $post) :
                setup_postdata($post);
                ?>
                <div id="post-<?php the_ID(); ?>" <?php post_class('product'); ?>>	
                     <div class="post-info">
                         <h1 class="product_title">
                         <a href= "<?php the_permalink(); ?>" rel="bookmark" title="<?php echo sprintf(__("Permanent link to %s", 'rethink'), get_the_title(get_the_ID())); ?>">
                             <?php the_title(); ?>
                         </a>
                        </h1>
                             <div class="detail">
                                <ul class="post_meta">
                                    <li class="admin"><?php printf(__("Posted by %s", 'rethink'), get_the_author_link()); ?></li>
                                     <li class="date"><?php printf(__('Posted on %s', 'rethink'), get_the_time('F j, Y')); ?></li>
                                     <li class="category"><?php the_category(','); ?></li>                
                                     <li class="commentt"><?php comments_popup_link(__('No Comments.', 'rethink'), __('1 Comment.', 'rethink'), __('% Comments.', 'rethink')); ?></li>
                                </ul>
                            </div>
                     </div>
                     <div class="post_thumbnail_wrapper">
                         <?php if (has_post_thumbnail()) { ?>
                        <a href="<?php the_permalink(); ?>">
                             <?php the_post_thumbnail('post_thumbnail', array('class' => 'postimg')); ?>
                         </a>
                             <?php
                             } else {
                                         echo rethink_main_image();
                                     }
                                ?>
                    </div>
                    <div class="product_content"><?php the_excerpt(); ?><div class="buttons"><a class="btn-2" href="<?php the_permalink() ?>"><span><?php _e('Read Review', 'rethink') ?></span></a></div>
                    </div>
               </div>
      


             <?php endforeach;
            if(function_exists('wp_paginate')){
             wp_paginate();  }
    
            wp_reset_postdata(); ?>
            <div class="clear"></div>
               
     <?php   endwhile;
    else:
    ?>
    <div class="product">
        <p>
            <?php _e('Sorry, no posts matched your criteria.', 'rethink'); ?>
        </p>
    </div>
    
<?php endif; ?>
 
      

            </div>              
        </div>
    </div>
    <div class="grid_7 omega">
        <!--Start Sidebar-->
        <?php get_sidebar(); ?>
        <!--End Sidebar-->
    </div>       
</div>
<?php get_footer(); ?>

我如何显示我的编码的分页??? 对不起,如果代码行不整齐,我还是新手

1 个答案:

答案 0 :(得分:0)

更新此代码:

if(function_exists('wp_paginate')){
   wp_paginate();  
}

此代码:

if(function_exists('wp_paginate')){
   wp_paginate(array('page' => 'page'));  
}