WordPress,分页函数不起作用(自定义主题)



我正在使用WordPress构建自定义主题,并为我的新闻项目制作了自定义帖子类型档案。我想使用paginate();功能可导航我的物品。此功能尚未起作用,我在做什么错?

<div class="col-md-12">
            <?php 
            $args = array('post_type' => 'nieuws-item');
            $the_query = new wp_query( $args );
            while($the_query -> have_posts()) : $the_query -> the_post();?>
                    <div class="col-md-6 left">
                        <div class="content-holder-nieuws fc3 left">
                            <h6><?php the_title(); ?></h6>
                            <h6 class="month fc2 left"><?php echo (types_render_field("nieuws-maand", array("output"=>"normal"))); ?></h6>
                            <div class="news-discription left">
                                <p class="fc5 left">
                                    <?php the_excerpt(); ?>
                                </p>
                                <a href="<?php the_permalink(); ?>" class="left read-more">
                                    <img src="<?php bloginfo('template_url'); ?>/img/readmore-border.png" class="readmore-border">
                                    lees meer
                                </a>
                            </div>
                        </div>
                    </div>
            <?php endwhile; ?></div>
        <div class="col-md-12 overview-navigation left">
            <?php paginate_links(); ?>
        </div>

自定义帖子类型内置了存档功能,您只需启用它即可。在您的register_post_type()调用中,将" has_archive"设置为true。

然后为存档页面创建一个模板文件(如果其格式与标准博客的格式不同)。在您的情况下,我猜您要称其为archive-nieuws-items.php。然后,在您的存档页面上,您可以简单地使用示例中的标准后循环而不是自定义版本。

采用这种方法,您将提高效率并处理分页问题。

进一步阅读:https://codex.wordpress.org/function_reference/register_post_typehttps://developer.wordpress.org/themes/basics/template-hierarchy/

最新更新