自定义帖子类型分页

发布于 2024-12-12 00:33:12 字数 531 浏览 0 评论 0原文

我正在尝试打印多种帖子类型的多个帖子。但是,我似乎无法实现分页 - 一旦我转到 .../category.../page/2 ,我就会收到页面未找到错误。看起来它甚至没有尝试读取我的 archive.php 文件中的内容。

我 100% 确定永久链接没有问题,因为我尝试过重置它们等。

我想这与管理设置中每页帖子数设置为 10 的事实有关,但我确实需要能够动态编辑这个数字。

我在这里尝试了各种修复方法,但似乎都不起作用: http://wordpress.org/support/topic/pagination-with-custom-post-type-getting-a-404?replies=1#post-1616810

抱歉,如果这是一个高度重复的问题 - 我发现没有其他修复对我有用。

多谢!

I'm trying to print out a number of posts from multiple post types. However, I can't seem to implement the pagination - once I go to .../category.../page/2 I get a page not found error. It seems like it doesn't even try to read what's inside of my archive.php file.

I'm 100% sure that there's no problem with permalinks, since I've tried resetting them and etc.

I suppose it has something to do with the fact that in admin settings the number of posts per page is set to 10, but i really need to be able to edit this number dynamically.

I've tried a variaty of fixes from here, but non of them seem to work: http://wordpress.org/support/topic/pagination-with-custom-post-type-getting-a-404?replies=1#post-1616810

I'm sorry if it's highly repetitive question - none of other fixes I found worked for me.

Thanks a lot!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彡翼 2024-12-19 00:33:12

你可以做这样的事情(未经测试):

$posts_per_page = 10;
$post_type = 'YOUR_POST_TYPE'

$args = array( 'post_type'=> $post_type, 'posts_per_page' => $posts_per_page, 'paged' => get_query_var('paged') );

query_posts( $args );

// here loop

You can do something like this (not tested):

$posts_per_page = 10;
$post_type = 'YOUR_POST_TYPE'

$args = array( 'post_type'=> $post_type, 'posts_per_page' => $posts_per_page, 'paged' => get_query_var('paged') );

query_posts( $args );

// here loop
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文