This plugin hasn’t been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

XHTML Content Negotiation for WordPress


A plugin to allow WordPress to serve content using the application/xhtml+xml MIME type, based on the client’s HTTP ACCEPT request. It also takes into account the q-values of the request, in compliance with RFC2616 HTTP/1.1. The plugin also handles clients that don’t supply an ACCEPT header (e.g., the W3C Validator).

The plugin detects IE8 and lower and serves content as text/html, because it doesn’t follow the HTTP 1.1 requirement and can’t parse application/xhtml+xml anyway.

Note: if you use this plugin, you MUST ensure that you have and appropriate DTD and XHTML namespace in your document. If you don’t, some browsers may render your document as an XML tree. You must also ensure that your theme produces well-formed and valid XHTML, otherwise you will get XML parsing errors in your browser.

This plugin requires PHP version 5 or greater.

If you come across any bugs or have suggestions, please use the plugin support forum or contact me at Please check the FAQ for common issues.


  1. Upload plugin-name.php to the /wp-content/plugins/ directory
  2. Activate the plugin through the ‘Plugins’ menu in WordPress


Google Adsense does not work with this plugin. Why?

That is a problem with Google Adsense which assumes that you will be sending content as text/html, and it breaks if you send it as application/xhtml+xml. This web page offers a Javascript-based solution that seems to work, and doesn’t upset Google.

My browser is giving me an XML parsing error.

This means that your theme is producing invalid XHTML, and you probably need to contact the theme authors. I find that this is most often caused by using invalid HTML entities in the document.

My browser is rendering the document as an XML tree.

This means that your DTD and/or XHTML namespace are incorrect. Check to make sure that the DTD is a valid XHTML doctype and that your html tag contains the XHTML namespace (xmlns="").

Contributors & Developers

“XHTML Content Negotiation for WordPress” is open source software. The following people have contributed to this plugin.



  • Added detection for IE9 which supports application/xhtml+xml


  • Fixed a bug where some q-values were parsed incorrectly.
  • Inserted class wrapper


  • Fixed a bug from version 1.2 that caused a PHP “unknown modifier” warning (thanks to Matt).


  • Added a check for MS Pocket IE, which would otherwise have been served XHTML
  • Restructured some code for readability and extensibility (thanks to Craig Loftus)


  • There was no catch-all return if the q-value evaluation was inconclusive – fixed
  • Tidied up some code for readability