Remove Comments RSS Feed from Wordpress Version 3.x

Below is the code to remove the comments rss feed but keep the normal rss feed. Put this code in the functions.php file in your template. If there is no functions.php file then add one placing the code between <?php and ?>

add_theme_support('automatic-feed-links');
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'feed_links_extra', 3 );
add_action( 'wp_head', 'threedmg_feed_links', 2 );

/**
 * Display the links to the general feeds.
 *
 * @since 2.8.0
 *
 * @param array $args Optional arguments.
 */
function threedmg_feed_links( $args = array() ) {
    if ( !current_theme_supports('automatic-feed-links') )
        return;

    $defaults = array(
        /* translators: Separator between blog name and feed type in feed links */
        'separator'    => _x('&raquo;', 'feed link'),
        /* translators: 1: blog title, 2: separator (raquo) */
        'feedtitle'    => __('%1$s %2$s Feed'),
        /* translators: %s: blog title, 2: separator (raquo) */
        'comstitle'    => __('%1$s %2$s Comments Feed'),
    );

    $args = wp_parse_args( $args, $defaults );

    echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr(sprintf( $args['feedtitle'], get_bloginfo('name'), $args['separator'] )) . '" href="' . get_feed_link() . "\" />\n";
}


If you want to just remove all feeds then use.
remove_theme_support('automatic-feed-links');
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'feed_links_extra', 3 );

Comments

Popular posts from this blog

qshape command not found - Postfix

Using variables within ajax success function that were set before ajax call (JQuery)