My custom post type is registered with 'public' as false and I'm querying with a WP_Query() object. arg's 'post_type' set to private too. The url is site.com/?post_type=my_post_type
I've tried to set 'exclude_from_search' attribute to false when registering the , but that didn't get me back the posts. From the docs, it seems that the above url query will be affected. My page is the single-my_custom_post_type.php in the theme folder.
I'm guessing I'll have to create a page with a custom page template in order to have an URL that's not affected by the the front-end search or public queryable attribute.
The question is really is there anyway to keep the default url ?post_type=... and still be able to query the private post type. Thanks.
Answer: Here are the attributes I used:
'public' => false, 'publicly_queryable' => true, 'exclude_from_search' => true,
Since I want to keep the default URL with post_type query parameter, the publicly_queryable attribute has to be true. To not show to others, I'd have to do conditionals to check whether or not to show the page to the current user.