如何在WordPress中将自定义帖子类型设为父页面?

时间:2017-02-19 22:34:52

标签: wordpress custom-post-type

我希望让一系列网页拥有我创建的自定义帖子类型的父级。例如,我的自定义帖子类型"Hospitals"可能包含"Some Hospital Name"条目,该条目可能包含多个页面,这些页面具有"contact us"等通用页面内容。我需要此联系我们页面,以"website.com/some-hospital-name/contact-us"目前为"website.com/contact-us"

1 个答案:

答案 0 :(得分:0)

初始化自定义帖子类型时,您可以将其指定为' hierarchical'作为其$ args的一部分。如果是等级的'设置为true,您还必须指定' page-attributes'在'支持'参数,以便在编辑器中显示父选择框。

$args = array(
    'hierarchical' => true,
    'supports' => array( 'title', 'editor', 'page-attriutes' )
);

请参阅WordPress Codex中的register_post_type参考:https://codex.wordpress.org/Function_Reference/register_post_type