Getting a valid list of post types

When calling get_post_types() in my plugin, I used it with
array( 'exclude_from_search' => false )
or
array( 'exclude_from_search' => false, 'public' => true )
but both of these include attachments, even though the front end search does not find an attachment.
If I use
array( 'exclude_from_search' => false, 'publicly_queryable' => true )
it does not include pages.
I thought to use 'show_in_nav_menus' => true, but the site I’m testing on happens to have a custom post type that I want searchable but not in the menus.
Trying 'query_var' => true, posts and pages are not returned.
I think 'has_archive' is similar (in that it could be boolean or string), but it won’t show pages.

What do you think? Should I use the first one and remove attachment from the array? Is there something I missed?

That is what I would do, yes.

I think you should the first one, too. As a quick solution.

But if this still bugs you, or you want to be very thorough, you could just pluck the actual data directly from the global $wp_post_types - the comments to the actual register_post_type function, found in wp-includes/post.php feel a little bit more helpful than the usual WP dev manual chaos.

If it was me, I’d probably do both, because I’m a person who really wants to KNOW thoroughly what makes things tick. First, the quick solution so that its solved, esp. if its a client job, and then to figure out WHY this didnt work as expected - even if the solution turns out to be the same :slight_smile:

cu, w0lf.