query private custom post type

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.

Read more here: query private custom post type

Leave a Reply

Your email address will not be published. Required fields are marked *