[英]How do have prev and next links on custom querys wordpress?
I have a custom template I am using for my page and in that custom template I get the_content()
then I use a custom query. 我有一个用于页面的自定义模板,在该自定义模板中,我得到
the_content()
然后使用自定义查询。 I want to be able to only get 6 of my posts then be able to go to prev and next to see the rest of the posts. 我希望只能获得6个帖子,然后可以转到上一页和下一页查看其余帖子。
Here is some of my code: 这是我的一些代码:
<?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>
?> ?>
Try this 尝试这个
<?php posts_nav_link();
Reference: http://codex.wordpress.org/Next_and_Previous_Links 参考: http : //codex.wordpress.org/Next_and_Previous_Links
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.