admin管理员组文章数量:1279182
This
add_action('init', function() {
add_rewrite_rule('^foo', 'index.php?category_name=category1', 'top');
});
works and allows example/foo/
to display all the posts from category1
.
But then the pagination doesn't work.
There is a link on the bottom of this page that shows "Older posts", and that redirects to example/foo/page/2/
.
Question: how to have example/foo/page/2/
display all the posts from category1
, page 2?
(without a third party plugin)
This
add_action('init', function() {
add_rewrite_rule('^foo', 'index.php?category_name=category1', 'top');
});
works and allows example/foo/
to display all the posts from category1
.
But then the pagination doesn't work.
There is a link on the bottom of this page that shows "Older posts", and that redirects to example/foo/page/2/
.
Question: how to have example/foo/page/2/
display all the posts from category1
, page 2?
(without a third party plugin)
1 Answer
Reset to default 1Solved with:
add_rewrite_rule('^foo/page/([0-9]+)/?$', 'index.php?category_name=category1&paged=$matches[1]', 'top');
add_rewrite_rule('^foo', 'index.php?category_name=category1', 'top');
The order between these two lines here is important.
See also Permalink/Pagination issue: Category base name same as page name.
本文标签: phpRewrite with pagination foopage2 to posts of a given categorypage 2
版权声明:本文标题:php - Rewrite with pagination foopage2 to posts of a given category, page 2 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741223908a2361498.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论