WordPress自定义主题分页问题

时间:2019-05-01 12:12:13

标签: pagination wordpress-theming

我正忙于在wordpress中开发自定义主题。我对自定义新闻存档页面的分页有一些问题。我在浏览器中看到de next_posts_link()previous_posts_link()链接,但是当我单击它时,没有任何反应。在默认的wordpress主题二十六个中,我可以看到,当您单击下一页按钮时,网址从http://localhost/wp /到http://localhost/wp/?paged=2

有人可以帮我吗?

<?php

    $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 2;
    $args = array(
    'post_type'         => 'nieuwsbericht',
    'posts_per_page'    => 2,
    'paged'          => $paged

    );

    $nieuwsberichten = new WP_Query( $args );

    if ( $nieuwsberichten->have_posts() ) : 
?> 

<div class="container-fluid float-left newspage">
    <?php while ( $nieuwsberichten->have_posts() ) : $nieuwsberichten->the_post(); ?>
    <div class="col-md-12 float-left newsitem">
        <div class="col-md-4 float-left">
            <img src="<?php bloginfo('template_url'); ?>/img/content_1.jpg" class="overflow-hidden col-md-12">
        </div>
        <div class="col-md-8 float-left news-content">
            <p class="date fc1">December 2018</p>
            <h4><?php the_title(); ?></h4>
            <p class="fc4"><?php the_excerpt(); ?>
            </p>
            <a class="btn">Lees meer<img src="<?php bloginfo('template_url'); ?>/img/arrow.png" class="btn-arrow"></a>
        </div>
    </div>
<?php endwhile; ?>
<!-- pagination -->
<?php next_posts_link(); ?>
<?php previous_posts_link(); ?>
<?php else : ?>
<!-- No posts found -->
<?php endif; ?>
</div>
</div>
<?php 
    include 'footer.php';
?>

0 个答案:

没有答案