简体   繁体   English

自定义帖子类型下的自定义页面

[英]Custom page under custom post type

I have several custom post types, but for this question I will use just two, houses and condominiums . 我有几种自定义帖子类型,但是对于这个问题,我将只使用两种,即房屋和公寓

A condominium has a lot of houses. 一个公寓有很多房子。

I already created these two custom post types and it's working. 我已经创建了这两种自定义帖子类型,并且可以正常工作。 When I access archive-houses (/houses), it brings all the houses. 当我访问档案馆(/ houses)时,它会带走所有的房屋。 If I access archive-condominiums (condominiums), it brings all of it as well. 如果我访问存档共管公寓(共管公寓),它也会带来所有这些。

If I access single-condominiums (/condominiums/some-cond) and single-houses (/houses/some-house/), it shows the information for each item selected. 如果我访问单一公寓(/ condominiums / some-cond)和单一房屋(/ houses / some-house /),则会显示每个所选项目的信息。 Working as well! 工作正常!

Now, I would like to bring all the houses by condominiums, when I access something like this: 现在,当我访问以下内容时,我想将所有房屋都带上公寓:

/condominiums/{condominium}/{houses} / condominiums / {condominium} / {houses}

How to create this page with this hierarchy inside this custom post type? 如何在此自定义帖子类型中使用此层次结构创建此页面?

Thanks! 谢谢!

while registering post type for condominiums you might have used an array of arguments, on that add with_front argument with the desired url and than save permalinks, 在注册公寓的文章类型时,您可能使用了一个参数数组,在该数组上添加具有所需网址的with_front参数,然后保存永久链接,

check here https://codex.wordpress.org/Function_Reference/register_post_type 在这里检查https://codex.wordpress.org/Function_Reference/register_post_type

'with_front' => bool Should the permalink structure be prepended with the front base. 'with_front'=> bool永久链接结构是否应该在前基础之前。 (example: if your permalink structure is /blog/, then your links will be: false->/news/, true->/blog/news/). (例如:如果您的永久链接结构为/ blog /,则您的链接将为:false-> / news /,true-> / blog / news /)。 Defaults to true 默认为true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM