1

I have an RSS feed setup for my custom post types, but I'm trying to add in all posts with the status 'draft'. Here's what I've tried that doesn't seem to be working at the moment :

  function draft_to_rss($qv) {
      if (isset($qv['feed']) && $qv['post_type'] == 'extension_cpt' )
          $qv['post_status'] = array( 'publish' , 'draft' );
      return $qv;
  }
  add_filter('request', 'draft_to_rss');

Is it possible to enable drafts to show up in the RSS feed for a specific custom post type?

1 Answer 1

0

Yes.

Add something like the below to your functions.php. Or wherever you can execute custom code for your theme or plugin.

function query_adjustments($query) {
    if ( !is_admin() && $query->is_main_query() && is_feed()) {
        $query->set("post_status", array("draft", "publish"));
    }
}
add_action( 'pre_get_posts', 'query_adjustments' );

The above will add drafts for every RSS feed. You can inspect the query parameters to only include drafts under the circumstances suitable for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.