I have a lot of different custom post types like person, company, nonprofit, etc. I want to show a loop of their names but I also need to exclude some. Is there a way to give certain post types a shared label that I can then use as an argument to loop through them?
I don't think there's a way, in WP's native features, to give a post type, itself,
You can get post types in your code using
get_post_types( $args, $output, $operator ).
$post_types = get_post_types( $args, $output, $operator );
But the only way I can think of to exclude post types based on a mutual value/variable is by setting relevant
post type settings when registering the
post type' - e.g.
'publicly_queryable' => false.
And then, you can use
get_post_types() to find only the post types that have a particaulr value of, for example,
This may suffice for what you're trying to do. There is no 'post type meta` in WordPress to allow you to set a 'shared label' for the post types themselves.
If my fix above doesn't suffice, then maybe this plugin will be a good place to start (or at least look at it's code) -https://wordpress.org/plugins/wp-post-type-meta/.