使用get_post_types( [\'public\' => TRUE ], \'objects\' );
. 这将返回已翻译的帖子类型标签和其他信息。
测试示例:
add_action( \'wp_footer\', function() {
$post_types = get_post_types(
[ \'public\' => TRUE, \'_builtin\' => TRUE ],
\'objects\' // complete information, not just the name
);
foreach ( $post_types as $slug => $arguments )
print "$slug: {$arguments->labels->singular_name}<br>";
print \'<pre>\' . print_r( $post_types, 1 ) . \'</pre>\';
});