| 1207 | // Determine if we are looking at the main comment feed |
| 1208 | $is_main_comments_feed = ( $wp_query->is_comment_feed() && ! $wp_query->is_singular() ) ? true : false; |
| 1209 | |
| 1210 | /* |
| 1211 | * Check the queried object for the existence of posts if it is not a feed for an archive, |
| 1212 | * search result, or main comments. By checking for the absense of posts we can prevent rendering the feed |
| 1213 | * templates at invalid endpoints. e.g.) /wp-content/plugins/feed/ |
| 1214 | * |
| 1215 | */ |
| 1216 | if ( ! $wp_query->have_posts() && ! ( $wp_query->is_archive() || $wp_query->is_post_type_archive() || $wp_query->is_search() || $is_main_comments_feed ) ) { |
| 1217 | wp_die( __( 'ERROR: This is not a valid feed.' ), '', array( 'response' => 404 ) ); |
| 1218 | } |
| 1219 | |