如何使WordPress自定义帖子类型成为页面父项?
问题描述:
我期望让一系列页面拥有我创建的自定义帖子类型的父项。例如,我的自定义帖子类型"Hospitals"
可能有一个条目"Some Hospital Name"
,该条目可能有多个页面具有通用页面内容,如"contact us"
。我需要这个联系我们页面有一个"website.com/some-hospital-name/contact-us"
目前它的"website.com/contact-us"
slu slu。如何使WordPress自定义帖子类型成为页面父项?
答
初始化自定义帖子类型时,可以将其指定为“分层”作为其$ args的一部分。如果'等级'设置为true,则还必须在'supports'参数中指定'page-attributes',以便在编辑器中显示父级选择框。
$args = array(
'hierarchical' => true,
'supports' => array('title', 'editor', 'page-attriutes')
);
看到在WordPress的法典的register_post_type参考:https://codex.wordpress.org/Function_Reference/register_post_type