PHP Fatal error: Cannot redeclare get_avatar_url()


So my last post explaining how to resolve a WordPress issue got some really positive feedback and clicks, so I figured I would share my latest WordPress issue:

PHP Fatal error: Cannot redeclare get_avatar_url() (previously declared in /home/u356894638/public_html/wp-includes/link-template.php:3798) in /home/u356894638/public_html/wp-content/themes/custom_theme/functions.php on line 1: /home/u356894638/public_html/index.php

And in case you’re wondering if you’re experiencing the same problem I did, I should add that this caused my entire site to go down and be blank. I had to look in my Apache logs to find the error being thrown by WordPress. So now that we have the error and the symptoms of the problem, let’s move on to the answer…

As always, I like to says YMMV (your miles may vary), but I was able to resolve the issue by updating my theme (which I built). I had implemented a custom version of the function get_avatar_url which conflicted with the version built into WordPress core. I simply renamed the function and updated the files that used the function and the error went away.

I hope this helps someone. If you’re still having problems or need help, leave a comment and I’ll try to help. But I also recommend checking on the WordPress Support Forum – lots of super helpful and smart people. And if you already host your own WordPress instance or want to start, check out my list of Best WordPress Hosts.