admin管理员组文章数量:1130349
I have a Page, with Custom Page Template to display 6 "Posts" with a specific category on that page.
I have tried:
<div class="navigation">
<div class="alignleft"><?php previous_posts_link('« Previous Entries') ?></div>
<div class="alignright"><?php next_posts_link('Next Entries »','') ?></div>
</div>
But it shows same posts and not other posts, however the URL changes to page/1/ page/2 and so on.
What do i intend to have:
I want to have Next link to be displayed on the template and when it is clicked, the next set of Posts with same Category should load.
I tried to google for a solution can stumbled upon this post: / the solution used here is deprecated.
I have a Page, with Custom Page Template to display 6 "Posts" with a specific category on that page.
I have tried:
<div class="navigation">
<div class="alignleft"><?php previous_posts_link('« Previous Entries') ?></div>
<div class="alignright"><?php next_posts_link('Next Entries »','') ?></div>
</div>
But it shows same posts and not other posts, however the URL changes to page/1/ page/2 and so on.
What do i intend to have:
I want to have Next link to be displayed on the template and when it is clicked, the next set of Posts with same Category should load.
I tried to google for a solution can stumbled upon this post: http://blog.deconcept/2005/02/07/wordpress-next-previous-post-links/ the solution used here is deprecated.
Share Improve this question edited Sep 24, 2014 at 9:44 fuxia♦ 107k39 gold badges255 silver badges461 bronze badges asked Nov 28, 2012 at 8:05 SNaushadSSNaushadS 217 bronze badges 1- Please don't use third party services to add your code, add code directly to your question – Pieter Goosen Commented Sep 24, 2014 at 6:04
1 Answer
Reset to default 0It looks like you're missing the "$paged" variable. This controls the pagination, along with the "posts_per_page" option you have set.
Please see the following amended PasteBin: http://pastebin/U4teTA0F
This ensures that the correct page is set when using "/page/2". "/page/3", etc.
Code:
<div id="blogposts">
<?php
global $paged;
$catquery = new WP_Query( 'cat=1&posts_per_page=6&paged=' . $paged );
while($catquery->have_posts()) : $catquery->the_post();
?>
<ul>
<div id="post" style="max-width:400px;height:410px;border:solid thin red; float:left;margin: 70px 30px 35px;">
<p style="font-weight: bolder;"><?php the_time(get_option('date_format')); ?></p><h3 style="max-width: 100%; max-height: 12%; overflow: hidden;" ><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
<?php the_post_thumbnail(array(350,250)); // Crop 300 by 200 px image?>
<div id="para" style="width=350 height=233"><p style="margin: 4px 15px 9px 17px; max-width: 90%; max-height: 64px; overflow: hidden;"><?php the_excerpt(); ?><?php do_action( 'addthis_widget' ); ?></p>
</div>
</ul>
<?php endwhile; ?>
</div>
<?php global $paged; query_posts('paged='.$paged);?>
<div class="clear"></div>
<div class="navigation"><p><?php posts_nav_link(); ?></p></div>
</div>
I have a Page, with Custom Page Template to display 6 "Posts" with a specific category on that page.
I have tried:
<div class="navigation">
<div class="alignleft"><?php previous_posts_link('« Previous Entries') ?></div>
<div class="alignright"><?php next_posts_link('Next Entries »','') ?></div>
</div>
But it shows same posts and not other posts, however the URL changes to page/1/ page/2 and so on.
What do i intend to have:
I want to have Next link to be displayed on the template and when it is clicked, the next set of Posts with same Category should load.
I tried to google for a solution can stumbled upon this post: / the solution used here is deprecated.
I have a Page, with Custom Page Template to display 6 "Posts" with a specific category on that page.
I have tried:
<div class="navigation">
<div class="alignleft"><?php previous_posts_link('« Previous Entries') ?></div>
<div class="alignright"><?php next_posts_link('Next Entries »','') ?></div>
</div>
But it shows same posts and not other posts, however the URL changes to page/1/ page/2 and so on.
What do i intend to have:
I want to have Next link to be displayed on the template and when it is clicked, the next set of Posts with same Category should load.
I tried to google for a solution can stumbled upon this post: http://blog.deconcept/2005/02/07/wordpress-next-previous-post-links/ the solution used here is deprecated.
Share Improve this question edited Sep 24, 2014 at 9:44 fuxia♦ 107k39 gold badges255 silver badges461 bronze badges asked Nov 28, 2012 at 8:05 SNaushadSSNaushadS 217 bronze badges 1- Please don't use third party services to add your code, add code directly to your question – Pieter Goosen Commented Sep 24, 2014 at 6:04
1 Answer
Reset to default 0It looks like you're missing the "$paged" variable. This controls the pagination, along with the "posts_per_page" option you have set.
Please see the following amended PasteBin: http://pastebin/U4teTA0F
This ensures that the correct page is set when using "/page/2". "/page/3", etc.
Code:
<div id="blogposts">
<?php
global $paged;
$catquery = new WP_Query( 'cat=1&posts_per_page=6&paged=' . $paged );
while($catquery->have_posts()) : $catquery->the_post();
?>
<ul>
<div id="post" style="max-width:400px;height:410px;border:solid thin red; float:left;margin: 70px 30px 35px;">
<p style="font-weight: bolder;"><?php the_time(get_option('date_format')); ?></p><h3 style="max-width: 100%; max-height: 12%; overflow: hidden;" ><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
<?php the_post_thumbnail(array(350,250)); // Crop 300 by 200 px image?>
<div id="para" style="width=350 height=233"><p style="margin: 4px 15px 9px 17px; max-width: 90%; max-height: 64px; overflow: hidden;"><?php the_excerpt(); ?><?php do_action( 'addthis_widget' ); ?></p>
</div>
</ul>
<?php endwhile; ?>
</div>
<?php global $paged; query_posts('paged='.$paged);?>
<div class="clear"></div>
<div class="navigation"><p><?php posts_nav_link(); ?></p></div>
</div>
本文标签: nextpageNext Page Link shows same posts on custom template
版权声明:本文标题:nextpage - Next Page Link shows same posts on custom template 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749038485a2306755.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论