WordPress php fatal error: Call to undefined function language_attributes()?

How do I fix the following error.

Fatal error: Call to undefined function language_attributes()

Related posts

Leave a Reply

4 comments

  1. What version of WP are you using? From my research I found that the language_attributes() function is a new feature as of WP 2.1. If you are using a version of WordPress older than 2.1 then you can either remove the function call from your header.php file or upgrade your wordpress installation.

  2. This error occurs because the function language_attributes() is unavailable. If you are seeing it in the logs but your site is working fine, it might just be that someone tried to access a file in your theme directly.

    Files in the theme directory are normally accessed after WordPress has loaded (making a bunch of functions available, like language_attributes()). If you try to access them directly, for instance by visiting yoursite.com/wp-content/themes/yourtheme/header.php in your web browser, you should see an empty page, and an error should be logged (e.g. in the error_log file).

    Other files will trigger slightly different errors, depending of what functions these documents are calling. On a site I just tested, if I hit mytheme/index.php a Call to undefined function get_header()... error is logged.

    If you see this error in the logs but are not experiencing any issues, it’s probably due to some bot or indelicate user snooping around. You can ignore the error (unless you have a ton of them, in which case you might want to install a security plugin just in case…)