簡體   English   中英

自定義查詢wordpress的上一個和下一個鏈接如何?

[英]How do have prev and next links on custom querys wordpress?

我有一個用於頁面的自定義模板,在該自定義模板中,我得到the_content()然后使用自定義查詢。 我希望只能獲得6個帖子,然后可以轉到上一頁和下一頁查看其余帖子。

這是我的一些代碼:

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
            <div class="entry-content">

                <div id="the_content">                          
                    <?php the_content(); ?>
                </div>
                <?php 

                $args = array('numberposts'=> 6,
                                'post_type'=>'project'
                                ); 
                $posts = get_posts( $args );

                    if($posts){

                        foreach( $posts as $post ) :    setup_postdata($post);

                           //do stuff 

                             wp_reset_postdata();
                    endforeach;
                 endwhile;
               </div>
            </article>

?>

嘗試這個

<?php posts_nav_link();

參考: http : //codex.wordpress.org/Next_and_Previous_Links

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM