【问题标题】:why pagination in my wordpress theme is not showing (wp-paginate plugin)为什么我的 wordpress 主题中的分页没有显示(wp-paginate 插件)
【发布时间】:2018-12-10 17:55:10
【问题描述】:

我在 wordpress 中使用 rethink 主题,并使用 wp-paginate 插件

在arcive.php、category.php和index.php分页没问题 但是为什么 page.php 没有运行?

我创建了自己的模板来显示所有帖子 发布.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(); ?>

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

【问题讨论】:

    标签: javascript php html wordpress pagination


    【解决方案1】:

    更新此代码:

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

    到此代码:

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

    【讨论】:

    • 不起作用我应该把代码放在哪里?我试过了,但仍然没有显示分页
    猜你喜欢
    • 2013-07-04
    • 2012-07-10
    • 1970-01-01
    • 2021-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多