[英]WordPress Posts Pagination Not Working
I am having problems with the post pagination of this certain category. 我在某些类别的分页中遇到问题。 I have this working 'Previous' and 'Next' using the previous_post_link()
and next_post_link()
. 我使用previous_post_link()
和next_post_link()
使此“ Previous”和“ Next” next_post_link()
。 I have several issues regarding this. 我对此有几个问题。 I'll just number it so it will be organized. 我将对其编号,以便将其组织起来。
Please see image of what I wanted to achieve, hope someone can give me a link of a tutorial that does that. 请查看我想要实现的图像,希望有人可以给我提供该链接的教程。 I am open to plugins. 我对插件持开放态度。
Thanks in advance for the help, hope I did not confuse any of you of these several problems. 在此先感谢您的帮助,希望我不要让您对这几个问题感到困惑。
I found the solution for item #1. 我找到了第一项的解决方案。 I stumbled upon this code: 我偶然发现了以下代码:
<?php
$args = array(
'cat' => 39,
'posts_per_page' => 1,
'order' => 'ASC'
);
$my_query = new WP_Query($args);
while ($my_query->have_posts()) {
$my_query->the_post(); ?>
<a href='<?php the_permalink(); ?> ' >First Page</a> |
<?php }
wp_reset_query(); ?>
<?php previous_post_link('%link', '<< Previous', TRUE); ?> |
<?php next_post_link('%link', 'Next >>', TRUE); ?>
<?php $args['order'] = 'DESC';
$my_query = new WP_Query($args);
while ($my_query->have_posts()) {
$my_query->the_post(); ?>
| <a href='<?php the_permalink(); ?> ' >Last Page</a>
<?php } ?>
This is the link of the site: http://wordpress.org/support/topic/link-to-most-recent-post-in-one-category 这是网站的链接: http : //wordpress.org/support/topic/link-to-most-recent-post-in-one-category
Pagination Like : Prev 1 2 3 Next 分页像:上一页1 2 3下一页
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$news= new WP_Query(array(
'post_type'=>'post',
'posts_per_page' => 3,
'paged' => $paged,
));
if($news->have_posts()) :
while($news->have_posts()) : $news->the_post();
the_title();
endwhile;
$total_pages = $news->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => '/page/%#%',
'current' => $current_page,
'total' => $total_pages,
'prev_text' => __('« prev'),
'next_text' => __('next »'),
));
}
?>
<?php else :?>
<h3><?php _e('404 Error: Not Found', ''); ?></h3>
<?php endif; ?>
<?php wp_reset_postdata();?>
Would you please check above code? 您能检查一下上面的代码吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.