Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action( 'wp', 'remove_comments_feed_for_posts' );
- function remove_comments_feed_for_posts() {
- if ( is_singular( 'post' ) ) {
- remove_action('wp_head', 'feed_links_extra', 3 );
- }
- }
- add_action( 'template_redirect', 'disable_comment_feed_for_posts' );
- function disable_comment_feed_for_posts() {
- if ( is_comment_feed () && get_post_type() === 'post' ) {
- global $wp_query;
- // Mark the current query as a 404
- $wp_query->set_404();
- // Return 404 HTTP status code instead of the default 200
- status_header(404);
- // By default, this page returns XML, so we change the Content-Type header
- // Because we want to show a 404 page
- header('Content-Type: text/html; charset=utf-8');
- // Render the 404 template
- get_template_part( 404 );
- // You should exit from the script after that
- exit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement