首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何为像http://example.com/something?这样的路径指定模板

如何为像http://example.com/something?这样的路径指定模板
EN

WordPress Development用户
提问于 2022-01-28 16:55:12
回答 1查看 29关注 0票数 0

我创建了一个自定义的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

谢谢。

EN

回答 1

WordPress Development用户

回答已采纳

发布于 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/

票数 5
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/401944

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档