Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Chrissie Miille
Chrissie Miille
1,928 Points

Wordpress fatal error: cannot redeclare

Hi everyone!

I'm working on a website for someone, and everything was going fine until I tried to add a second google font theme to a "theme customizations" custom/functions.php file (from a plugin), and when I tried to publish it I got this message:

Fatal error: Cannot redeclare wpsites_google_fonts() (previously declared in /home/content/a2pnexwpnas03_data03/45/3343945/html/wp-content/plugins/theme-customisations-master/custom/functions.php:21) in /home/content/a2pnexwpnas03_data03/45/3343945/html/wp-content/plugins/theme-customisations-master/custom/functions.php on line 27

And now I can't access any pages on the site or go back into my admin dashboard anywhere to fix it! :(

Any help to fix it would be immensely appreciated!

Raymon Oleaga
Raymon Oleaga
19,298 Points

you tried to install the font via a plug-in? and then the error appeared??

If thats the case, Did you try taking that plugin out of the plugins folder. The site should be back up after that. then you can reinstall the a fresh copy of that plug in if you need it.

If this is not the problem, can you explain a little bit more detailed?

Chrissie Miille
Chrissie Miille
1,928 Points

Not exactly. I installed the "Theme Customisations" plugin by WooThemes, which would allow me to add custom css/php to my child theme without messing with the theme's code directly.

Then, I needed to add a few fonts for my neighbor (whose site this is) from Google Fonts. I added the first font just fine to the custom/functions.php file from the plugin (with the code coming from this site

Font works great.

But then I tried to add the same code for the second font, and I got the error from above and now it's all a mess. :/

I've seen the advice about accessing the folder and ftp, but I haven't been able to find that, which I guess might be my biggest problem at this point?

I'm not using FTP (if i'm using that term right), but rather going through my neighbor's GoDaddy account where her site is hosted. There's no cPanel. Just the choices of either "Manage" (which tries to take me to the WP admin dashboard but just returns the error above) and "Settings" (which doesn't have any file list but does have the option to restore the database and/or files from certain time points. Unfortunately the latest one was around 18 hours ago, and I've been working on the site all day and I would hate to have to do that all over again).

Raymon Oleaga
Raymon Oleaga
19,298 Points

Gotcha,

so the problem is that you added the same exact code twice with same names and everything so yes this would cause problems.

If all you used that plug in for was to add the fonts then this could be an easy fix. but you do need to connect via FTP and like I said before remove the plug in from the plugins folder and go from there.

If you cant get to CPanel maybe is a good idea to call goDaddy and get all the information you need to connect via FTP they will be able to help you.

You can download something like fileZilla or Cyberduck to connect via FTP. you will need HOSTNAME, USERNAME, PASSWORD then go from there.

I wouldnt panic... you will get it back hehe :)

PS when develping WP sites or any.... is best to work locally then upload when you are ready.

again, most import, DONT PANIC everything will be ok. call goDaddy

Chrissie Miille
Chrissie Miille
1,928 Points

Oh...so that will cause an error even if I changed the font name in the second one? That's lame. :/ :P

Is it absolutely necessary to call GoDaddy if I already have that info? Or is there something specific they have to do?

And so once I do connect via FTP, will that just automatically fetch all the files as they are? Or will it do something further to them that I should know about?

Thanks for the advice. I'm feeling a lot better about the situation already. :)

Edit: While I'll be sure to try to do more developing locally in the future, would there be any harm done if I removed Filezilla from my computer after I fixed the problem?

Chrissie Miille
Chrissie Miille
1,928 Points

Update: Raymon you are my hero!! :D

So, I got connected and everything, and located the plugin's folder.

So do I just delete it? Is it just as easy as pressing the delete key? Or is there a specific button within filezilla I should use? And once I delete it, is there something I need to press as a sort of "Refresh/Publish" button? (Sorry for the probably simple questions. I just really don't want to dig myself into a further hole.)

1 Answer

Raymon Oleaga
Raymon Oleaga
19,298 Points

Yeah, just in case drag the plug in to your desktop and save there (but am sure yo can just reinstall later) then delete that plug in.

Once you remove it everything should be back to normal.

You wouldn't need FileZilla once you are done but if you are planning on developing more sites you will need something like FileZilla so no Harm in having it.

If in any case that doesn't work then you will need to go into the function.php and remove that extra copy of the code but I don't think you will need to,

Keep me post it! Hope that gets it done. If not am sure we can figure out a way!

;)

Chrissie Miille
Chrissie Miille
1,928 Points

Awesome! And I might keep it, though I think I'm mostly asking for the sake of wanting to explore my options of FTPs later on. :P

And just tried it deleting it and all and IT WORKS AGAIN!!! :D

(whoops totally forgot to finish this)

Everything's back to normal now. And, I got a little more knowledge about FTPs. Thank you so much! :D