WordPress 3.1+ - 自定义帖子类型 - 单一模板 - 下一个和上一个导航链接
我使用的是 WordPress 3.1,
我有 3 种自定义类型:视频、画廊和播客。他们使用默认的分类类别。
当查看单个自定义帖子(假设是视频)时,next_post_link()(或 previous_post_link)函数按计划工作,但它仅链接到此自定义帖子类型的下一个或上一个帖子。
我怎样才能让它显示任何帖子类型的下一篇帖子?试图在谷歌上搜索时间,但没有找到任何与此相关的内容。有人面临同样的问题吗?
I'm using wordpress 3.1
I got 3 types of custom types : videos, galleries and podcasts. They use the default taxonomy categories.
When viewing a single custom post let's say a video, the next_post_link() (or previous_post_link) function works as planed but it links only to the next or previous post from this custom post type.
How could I get it to display the next post from any post type? tried to search hours on google without finding anything relevant to this. Anyone facing the same issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要从用于检索相邻帖子的 SQL 查询中删除
post_type
子句。这可以通过挂钩get_next_post_where
和get_previous_post_where
过滤器来完成,尽管这并不理想,因为 SQL 查询作为单个字符串传递。You'll need to remove the
post_type
clause from the SQL query used to retrieve the adjacent post. This can be done by hooking into theget_next_post_where
andget_previous_post_where
filters, although it's not ideal as the SQL query is passed as a single string.