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?

  • Just to confirm - you want to loop through the post types themselves, rather than their posts?
    – Dan.
    Nov 27, 2016 at 15:15
  • Correct. Like person, company, nonprofit
    – user300979
    Nov 27, 2016 at 15:18
  • Ok cool. See my answer below.
    – Dan.
    Nov 27, 2016 at 15:28

1 Answer 1


I don't think there's a way, in WP's native features, to give a post type, itself, meta.

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, publicly_queryable.

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/.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.