When I try to use next_posts_link()
and previous_posts_link()
in my archive
posts page I got a 404 error
page.
I'm using this permalink setting /%category%/%postname%
and working well for all pages like site/contacts
or posts like site/category/this-is-a-post-tile
.
The only problem is in archive posts, for test I've set the number of posts per archive by 1 per page and trying with three articles to change the pages.
The paginator is simple this:
<?php get_header(); ?>
</header>
<section class="large-9 columns right-dashed articles">
<?php if (have_posts ()) : while (have_posts ()) : the_post(); ?>
<article class="left-icon article" id="post-<?php the_ID(); ?>">
<a class="permalink" href="<?php echo get_permalink();?>"><h2 class="black"><?php the_title(); ?></h2></a>
<div class="details"><?php echo __('di:').' '.get_the_author();?> / <time datetime="<?php echo get_the_date('Y-m-d H:i:s');?>"><?php echo get_the_date();?></time></div>
<div class="entry"><?php the_excerpt(); ?></div>
<br><br>
<a class="button" href="<?php echo get_permalink();?>"><?php echo __('Continue to article'); ?></a>
<br><br><br>
<hr>
</article>
<?php endwhile; endif; ?>
<footer>
<?php
// PAGINATOR
next_posts_link();
previous_posts_link();
?>
</footer>
</section>
<aside class="large-3 columns to-right">
<?php
// some menu here
?>
</aside>
<?php get_footer(); ?>
I'va always had mistakes with permalinks and pages, probably I miss some base concept of WordPress
about it.
How can I do to make it work and let WordPress paginate blog
pages correctly?
When I try to use next_posts_link()
and previous_posts_link()
in my archive
posts page I got a 404 error
page.
I'm using this permalink setting /%category%/%postname%
and working well for all pages like site.com/contacts
or posts like site.com/category/this-is-a-post-tile
.
The only problem is in archive posts, for test I've set the number of posts per archive by 1 per page and trying with three articles to change the pages.
The paginator is simple this:
<?php get_header(); ?>
</header>
<section class="large-9 columns right-dashed articles">
<?php if (have_posts ()) : while (have_posts ()) : the_post(); ?>
<article class="left-icon article" id="post-<?php the_ID(); ?>">
<a class="permalink" href="<?php echo get_permalink();?>"><h2 class="black"><?php the_title(); ?></h2></a>
<div class="details"><?php echo __('di:').' '.get_the_author();?> / <time datetime="<?php echo get_the_date('Y-m-d H:i:s');?>"><?php echo get_the_date();?></time></div>
<div class="entry"><?php the_excerpt(); ?></div>
<br><br>
<a class="button" href="<?php echo get_permalink();?>"><?php echo __('Continue to article'); ?></a>
<br><br><br>
<hr>
</article>
<?php endwhile; endif; ?>
<footer>
<?php
// PAGINATOR
next_posts_link();
previous_posts_link();
?>
</footer>
</section>
<aside class="large-3 columns to-right">
<?php
// some menu here
?>
</aside>
<?php get_footer(); ?>
I'va always had mistakes with permalinks and pages, probably I miss some base concept of WordPress
about it.
How can I do to make it work and let WordPress paginate blog
pages correctly?
Old post, but one of few I have found. I had the same issue in WP 6.7.1 with WordPress 2025 template.
Navigation to page 2 of posts of a certain category generates a link in the format .../category-name/page/2/
.
When I have permalinks setting to /%category%/%postname%/
than link sends me to 404, when I changed it to /%category%/%year%/%postname%/
it works fine.
I guess with first setting there is some problem, that WP assumes that page/2
is post that don't exist and so sends you to 404, but i do not have time/mood to examine in detail, this workaround works and is acceptable for me, maybe it will be for sb else as well.
check your reading settings. The number of post per page has to be the same in archives too.
wp-admin > options > reading
– vitto Commented May 3, 2013 at 14:32next_posts_link
andprevious_posts-link
with the same permalink structure. Something is peculiar about your site. Disable your plugins and switch themes. Try to find what is causing this. – s_ha_dum Commented May 3, 2013 at 14:50Advanced Custom Fields
,Disqus Comment System
,Flexible Custom Post Type
,WPML Multilingual CMS
andWPML String Translation
, refreshed the page multiple times, but the problem still the same. This is the url I call:site.com/category/page/2
does it points toarchive.php
or should I point to somewhere else? I'm not using other sub archives. – vitto Commented May 3, 2013 at 16:27