Update WP User Agent

I’ve seen a few cases where services will block the WP user agent used to fetch remote data. The most recent in this was https://www.us-cert.gov/ncas they offer a RSS feed but when trying to display it in a WordPress RSS widget you would get a invalid feed warning message instead of the feed itself.

Thanks to this issue opened up in the WordPress.org support forums there was a solution. So I bundled it up in a simple Plugin and am offering it here. The code is incredibly simple.

add_action( 'http_headers_useragent', 'wpsm_change_user_agent' );
function wpsm_change_user_agent() {

It updates the user agent to be the default Simplepie user agent. Simplepie is the library used to help fetch RSS data in WordPress.

You can download the plugin from here.


%d bloggers like this: