I've registered an employers
post type with several associated taxonomies and want to all associated pages (single, term archives, post type archive page) only viewable by logged-in users.
I've played around with the capabilities
argument for register_post_type()
and looked at the map_meta_cap
filter, but just can't quite put the pieces together. It seems that maybe I need to use a custom capability but that feels like overkill for this one feature. I've seen some references to using the template_redirect
feature too but not sure if that's the right way to go.
Despite a lot of searching, I'm struggling to answer what feels like a simple question. How can I restrict access of a custom post type or custom taxonomy to logged-in users of any capability?
I've seen "Restrict custom post type view by user role" but that's only filters the_content
. I've also looked a lot at "Restrict custom post type to only site administrator role" but it seems more about logged-in users. Finally "Set posts of a custom post type to be private by default?" only sets the post status meaning that an editor could accidentally make the post public which is a dealbreaker.