我创建了一个自定义的post类型(‘探索’),我们在网站中使用。本节的页面位于http://example.com/explore/page-name
这些页面工作得很好,但是如果用户退出该url并转到http://example.com/explore,他们将得到一个通用的index.php页面,这不是我们希望人们在这里看到的。
考虑到这个url没有指向任何内容,我如何指定使用哪个模板?我可以回显get_post_type(),它将'explore'显示为post类型,但我从index.php模板中看到了这一点。
我试着添加了一个page-explore.php,但这不起作用。似乎没有一个index-[custom-type].php
谢谢。
发布于 2022-01-28 17:11:03
您正在寻找“自定义post类型存档模板”。这是archive-{post_type}.php,或者在您的例子中是archive-explore.php:
https://developer.wordpress.org/themes/template-files-section/custom-post-type-template-files/
https://wordpress.stackexchange.com/questions/401944
复制相似问题