You could try forcing a 404
using this method:
/**
* Force 404 on all "alerts" custom post type pages except for the feed
*
* @see https://wordpress.stackexchange.com/a/162303/26350
*/
add_action( 'template_redirect', function() {
if( 'alerts' === get_post_type() && ! is_feed() )
{
$GLOBALS['wp_query']->set_404();
status_header( 404 );
nocache_headers();
}
} );
with the following setup:
$alert_args = array(
'public' => true,
'show_ui' => true,
'has_archive' => true,
'exclude_from_search' => true,
'label' => 'Alerts',
'supports' => array( 'title', 'editor' ),
);
register_post_type( 'alerts', $alert_args );
to allow only access to the feed for the the alerts
custom post type.
You might also want to consider adding an extra ! is_user_logged_in()
check, if you want to allow logged in users view the alerts or ! current_user_can( 'some_capability' )
for some user capability requirement.