Fix WordPress Fatal error: Call to undefined function

If you get an error like this, there is a plugin or other function called in your theme which you don’t have. How do you fix this? There are a few ways: remove the code, error proof it, get the necessary plugin, or upgrade WordPress if necessary. In this quick WordPress tip post we’ll go over how to error proof these with a conditional tag and PHP function known as: function_exists.

If you get an error such as Fatal error: Call to undefined function the_title_attribute() you can simply replace any instance of the_title_attribute with the following:

<?php if (function_exists('the_title_attribute')) { the_title_attribute(); } ?>

In this case, you could also take it one step further by adding an else statement.

<?php if (function_exists('the_title_attribute')) { the_title_attribute(); } else { the_title(); } ?>

Before trying a new theme on a production site, make sure to preview your theme first, and then work out all the errors (if any).


About the editorial team

Editorial Team at IsItWp is a team of WordPress experts led by Syed Balkhi.