Wordpress 如何禁用自定义 post 类型的子页面

Wordpress how to disable child pages for custom post types

我有一个名为 designscustom post type

designs 是这样注册的:

register_post_type(
  'Designs',
  theme_build_post_args(
    // $slug, $singular, $plural
    'designs',
    'Design',
    'Designs',
    array(
      'menu_icon' => 'dashicons-admin-appearance',
      'menu_position' => 20,
      'has_archive' => false,
      'public' => false,
      'supports' => array('title'),
    )
  )
);

对于这种 post 类型,我不希望访问以下 URL:

我只是用这个 post type 来提取块的数据,它不是标准的一级和二级布局。

根据我在网上看到的,'has_archive'=> false 是我实现上述目标所需要的,但是,它对我不起作用?在后端,存在“查看”design post 的选项,但不应该存在,因为它不应该为其生成页面?

尝试添加此参数:'publicly_queryable' => false 当您注册自定义 post 类型时。它应该能帮到你!

来自register_post_typeDocs

publicly_queryable:
Whether queries can be performed on the front end as part of parse_request().
If false, previewing/viewing of your custom post will return 404s.

register_post_type(
  'Designs',
  theme_build_post_args(
    // $slug, $singular, $plural
    'designs', 'Design', 'Designs',
    array(
      'menu_icon' => 'dashicons-admin-appearance',
      'menu_position'=> 20,
      'has_archive'=> false,
      'public' => false,
      'publicly_queryable' => false,
      'supports'=> array('title'),
    )
  )
);

如果你能让它工作,请告诉我!