That wasn’t quite there yet.
The function was still adding all these extra post types that really weren’t wanted to the feed, so let’s limit that to just posts and pages.
public static function request_filter( $query ) {
if (isset($query['feed']) && (!isset($query['post_type']) || $query['post_type'] == 'post' || $query['post_type'] == 'page' || $query['post_type'] == array('post' => 'post') || $query['post_type'] == array('page' => 'page') )) {
$args = array( 'public' => true); // array('exclude_from_search'=>false); // ugh. WP has bad support here.
$post_types = get_post_types($args);
unset($post_types['revision']);
unset($post_types['nav_menu_item']);
if (defined('CCTM_DEBUG') && CCTM_DEBUG == true) {
$myFile = "/tmp/cctm.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
fwrite($fh, 'Request post-types:'. print_r($post_types, true));
fclose($fh);
}
/* Old foreach
foreach ($post_types as $pt) {
if('page' == $pt && self::get_setting('pages_in_rss_feed')) {
// Leave pages in.
}
elseif($pt == 'post') {
// Do nothing. Posts are always included in the RSS feed.
}
// Exclude it if it was specifically excluded.
elseif (!isset(self::$data['post_type_defs'][$pt]['include_in_rss']) || !self::$data['post_type_defs'][$pt]['include_in_rss']) {
unset($post_types[$pt]);
}
}
*/
foreach(self::$data['post_type_defs'] as $key => $pt) {
if('page' == $pt && self::get_setting('pages_in_rss_feed')) {
// Leave pages in.
}
elseif($pt == 'post') {
// Do nothing. Posts are always included in the RSS feed.
}
// Exclude it if it was specifically excluded.
elseif (!isset($pt['include_in_rss']) || !$pt['include_in_rss']) {
unset($post_types[$key]);
}
}
$query['post_type'] = $post_types;
}