【问题标题】:How can I make a custom post type be a pages parent in WordPress?如何使自定义帖子类型成为 WordPress 中的页面父级?
【发布时间】:2017-07-09 02:14:47
【问题描述】:

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

【问题讨论】:

    标签: wordpress custom-post-type


    【解决方案1】:

    当您初始化自定义帖子类型时,您可以将其指定为“分层”作为其 $args 的一部分。如果 'hierarchical' 设置为 true,您还必须在 'supports' 参数中指定 '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

    【讨论】:

      猜你喜欢
      • 2019-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-15
      • 1970-01-01
      • 2019-01-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多