WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to remove the default RSS feed, which I can successfully do by adding this in functions.php file.

remove_action( 'wp_head', 'feed_links', 2 );

However, It is important for me to use this in a function instead of using directly. For that purpose, I'm trying following:

function remove_rss() { 
    remove_action( 'wp_head', 'feed_links', 2 );
add_action('wp_head', 'remove_rss');

but that does not work. I think the reason is the wp_head loads after the feeds are loaded in the header. How can I make it load before the header adds the feeds? Thanks.

share|improve this question
Why can't you use the function by itself? – Joseph Leedy Jul 10 '12 at 12:32
possible duplicate of How to remove feeds from WordPress totally? – anu Jul 11 '12 at 14:57

Try this instead:

add_action( 'wp_head', 'wpse58023_wp_head', 1 );
function wpse58023_wp_head() {

    // Removes main feed link(s)
    remove_action( 'wp_head', 'feed_links', 2 );

    // Removes comments feed link
    remove_action( 'wp_head', 'feed_links_extra', 3 );

share|improve this answer

Try using init instead. According to the list of hooks, it runs before wp_head.

share|improve this answer

why don´t use remove_theme_support() with add_action('after_setup_theme', 'my_setup_theme') ?

function my_setup_theme() { 
  remove_theme_support( 'automatic-feed-links' );
add_action('after_setup_theme', 'my_setup_theme')
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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