Forums

is_feed() not working online (2 posts)

  1. smaxtastic
    Member
    Posted 4 months ago #

    Hey guys,

    I struggle solving this problem for a while now and decided to ask you. I use the following code to redirect my RSS feed links to FeedBurner:

    add_action( 'template_redirect', 'feed_redirect' );
    function feed_redirect() {
    	if ( is_feed() && !preg_match( '/feedburner|feedvalidator/i', $_SERVER['HTTP_USER_AGENT'] ) ){
    		header( 'Location: http://feeds.feedburner.com/smaxtra-edition' );
    		header( 'HTTP/1.1 302 Temporary Redirect' );
    	}
    }

    The strange thing is that this works just fine in my local testing environment (MAMP) but it does not work online at smaxed.com/feed.

    is_feed() seems to return false which is not the way it is supposed to act, right? Any hints? Thanks in advance, I appreciate this!

    Best regards,
    Stephan

    PS. I know that I can also try to use plugins or .htaccess redirects, but I thought using hooks is clean and sufficient.

  2. smaxtastic
    Member
    Posted 4 months ago #

    Sorry guys, flushing the cache did the trick!

Reply

You must log in to post.

About this Topic