I've had a request from a client which is causing me a bit of a headache! They want an RSS feed which shows content that isn't featured anywhere on the website.
I've registered a new custom post type (stripped down code);
$alert_args = array(
'public' => false,
'show_ui' => true,
'label' => 'Alerts',
'has_archive' => true,
'supports' => array( 'title', 'editor' ),
);
register_post_type( 'alerts', $alert_args );
For the RSS feed to work, it appears I need the public
argument set to TRUE
but I don't want these posts to be indexed by Google or to be used by website visitors. Any idea how I can get the RSS feed to work on it's own?
Thanks, Dan.
---EDIT---
Please note, in the end I had the change get_post_type()
to get_query_var( 'post_type' )
because the former doesn't work with archive template pages. See code;
if( 'alerts' === get_query_var( 'post_type' ) && ! is_feed() )
{
$GLOBALS[ 'wp_query' ]->set_404();
status_header( 404 );
nocache_headers();
}