wp分页未加载所有页面

时间:2018-12-18 01:34:29

标签: php wordpress

我有一个具有2种帖子类型的网站,并且实现了wp-pagination插件,该插件在存档页面上运行良好,但是将其插入名为page-products的模板文件时,该插件无法正常工作。该页面显示了两种帖子类型的所有帖子,到目前为止,我已经能够做到,但是无法显示分页,即使我通过插件设置强行显示,也只能显示1页,尽管我得到了50多个。我的代码有什么问题?

<div class="inner_cont">
                    <div class="content">
                        <ul class="artlist">
                            <?php
                                    $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
                                    $ppp = 16;

                                    $query_args = array(
                                        'paged' => $paged,
                                        'post_type' => array('product_gold', 'product_tool'),
                                        'posts_per_page' => $ppp,
                                    );


                                    $query = new WP_Query( $query_args );
                                    if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
                                    $thumbnail = wp_get_attachment_url(get_post_thumbnail_id($post->ID), 'gallery-thumb');
                                    if(empty($thumbnail)) $thumbnail = APP_URL . "images/cms/no-image.png";
                                ?>
                            <li>
                                <a href="<?php echo get_permalink(); ?>">
                                    <div class="img" style="background-image: url(<?php echo $thumbnail; ?>);">
                                        <img src="<?php echo APP_URL ?>images/top/mask_sp.png" alt="" class="mask">
                                    </div>
                                    <!-- .img -->
                                    <div class="text">
                                        <h3 class="tittle pc"><span class="number"><?php echo the_field('b-number'); ?> </span><?php echo mb_strimwidth(get_the_title(), 0, 25, '...'); ?></h3>
                                        <h3 class="tittle sp excpt"><span class="number"><?php echo the_field('b-number'); ?> </span><br><?php echo mb_strimwidth(get_the_title(), 0, 18, '...'); ?></h3>
                                        <h3 class="tittle sp ip5"><span class="number"><?php echo the_field('b-number'); ?> </span><br><?php echo mb_strimwidth(get_the_title(), 0, 15, '...'); ?></h3>
                                        <div class="down">
                                            <div class="dd">
                                                <p class="price"><?php echo the_field('a-price'); ?><?php echo the_field('b-price'); ?> $<span class="smalls">taxes</span></p>
                                                <span class="more pc">read</span>
                                                <span class="more sp">read more</span>
                                            </div>
                                        </div>
                                    </div>
                                </a>
                            </li>
                            <?php endwhile; ?>
                        </ul>

                    </div>

                </div>
                <div class="navw lst sp">
                    <ul class="subnav">
                        <li><a href="<?php echo APP_URL; ?>product/">すべての商品</a></li>
                        <li><a href="<?php echo APP_URL; ?>product_gold/">天然金</a></li>
                        <li class="pres"><a href="<?php echo APP_URL; ?>product_tool/">砂金採掘道具</a></li>
                    </ul>
                </div>
                <?php include($path.'libs/pagination.php'); ?>
                <?php endif; ?>

0 个答案:

没有答案