如何从 Google 隐藏 CPT 单页,同时允许在管理员中查看它们?

How to hide CPT single pages from Google while allowing to view them in admin?

register_post_type() 的参数中添加 public => false 将解决 Google 问题,但我无法访问管理员中的 CPT 帖子。重定向 like this 阻止查看页面,但它们仍显示在 Google.

我想要的有可能吗?

查看文档 (https://codex.wordpress.org/Function_Reference/register_post_type) - 内容如下:

public (boolean) (optional) Controls how the type is visible to authors (show_in_nav_menus, show_ui) and readers (exclude_from_search, publicly_queryable).

Default: false

  • 'true' - Implies exclude_from_search: false, publicly_queryable: true, show_in_nav_menus: true, and show_ui:true. The built-in types
    attachment, page, and post are similar to this.

  • 'false' - Implies exclude_from_search: true, publicly_queryable: false, show_in_nav_menus: false, and show_ui: false. The built-in
    types nav_menu_item and revision are similar to this. Best used if
    you'll provide your own editing and viewing interfaces (or none at
    all).

如您所见,public 是某种元 属性。将 public 设置为 false,但将 show_ui 设置为 true。这应该有效。