通过_builtin
参数到get_post_types()
, 只返回WordPress默认的帖子类型。
相反,只要通过public
作为论据,
以下是WooCommerce激活的开发站点上的输出示例:
var_dump(get_post_types([\'public\' => true]));
//result
array(4) {
["post"]=>
string(4) "post"
["page"]=>
string(4) "page"
["attachment"]=>
string(10) "attachment"
["product"]=>
string(7) "product"
}
不带参数(非public post类型随public一起返回):
var_dump(get_post_types());
//result
array(11) {
["post"]=>
string(4) "post"
["page"]=>
string(4) "page"
["attachment"]=>
string(10) "attachment"
["revision"]=>
string(8) "revision"
["nav_menu_item"]=>
string(13) "nav_menu_item"
["product"]=>
string(7) "product"
["product_variation"]=>
string(17) "product_variation"
["shop_order"]=>
string(10) "shop_order"
["shop_order_refund"]=>
string(17) "shop_order_refund"
["shop_coupon"]=>
string(11) "shop_coupon"
["shop_webhook"]=>
string(12) "shop_webhook"
}