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).

Subscribe to RSS

By: Leland on Jun. 1

Bookmark and Share

1 Comment »

Comment by John Subscribed to comments via email
2008-07-29 15:15:13

Hi ive just used:

And it worked for that file where i was previously getting the Fatal error.

Im now trying it for 2 sidebars of my theme so that i can place them into their own .php files.

The sidebars are named leftsidebar and rightsidebar, so i use the code as above and put in get_leftsidebar and get_rightsidebar but it goes wrong somehow and the layout gets messed up, im not sure where i may be making the mistake here though, any ideas please?

Thanks

John

 
Name (required)
E-mail (required - never shown publicly)
URI
Subscribe to comments via email
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.

Trackback responses to this post

Recent Comments

  • Leland: Phew…just got back from a vacation. I just moderated a ton of pending comments. Anyway…...
  • IndieLab: @ mike, You can contact me through my site, and I can give you a quote.
  • Mantra Lighting: Great job on the theme. Love the colors and it’s very clean!
  • Mayur: wow awesome theme dude :D Thanks for your god work
  • mike: im looking to get this theme set up any one want to make some money i suck at coding lol email me

About The Author

Welcome to Theme Lab. My name is Leland, and I run the place. I write all the tutorials and code all the themes you see here on the site.

For more information about me, feel free to read the about page. If you want to drop me a message, feel free to contact me.

Interested in advertising on Theme Lab? We have advertising available at very reasonable rates. Head on over to the advertising page for further details.

Please read our Privacy Policy and Terms of Service in regards to theme usage.

© 2008 - Theme Lab - Powered by WordPress