最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

categories - The default code for "posts_nav_link" on category.php isn't working

programmeradmin0浏览0评论

I am trying to make my own simple WP theme from scratch and I have run in to some difficulties. Maybe someone can help.

I have a category named "News", whose slug is "news".

The permalink structure in WP is set to:

/%category%/%postname%/

So, this category is accessible through .

I have made a simple template file named category.php. This is the template code:

<?php get_header(); ?>
<main>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>   
        <a href="<?php echo get_permalink(); ?>">
            <?php the_title(); ?>
        </a>
        <?php the_excerpt(); ?> 
        <?php the_date(); ?>
    <?php endwhile; else : ?>
        <?php _e( 'Sorry, no posts matched your criteria.' ); ?>
    <?php endif; ?>
    <?php posts_nav_link( ' · ', 'previous page', 'next page' ); ?>
</main>
<?php get_footer(); ?>

I have set the default amount of posts to show per page to 5, in WP's global "Reading settings". When this number is exceeded, a "Next page" pagination link occurs. Okay.

Here is the problem.

This "next page" link links to:


And that URL says: "Sorry, no posts matched your criteria"

Even though there ARE more posts in the category.

What am I missing?

发布评论

评论列表(0)

  1. 暂无评论