Gli errori di sintassi in WordPress possono sembrare schiaccianti, soprattutto se si è alle prime armi con la codifica.
Potreste incontrare questo problema quando aggiungete snippet di codice da tutorial. Anche un piccolo errore può danneggiare l’intero sito.
Se avete visto il temuto messaggio “Errore di sintassi, inaspettato…”, non c’è bisogno di farsi prendere dal panico: siete nel posto giusto! Abbiamo riscontrato e corretto questo errore molte volte sui nostri siti web e sappiamo come aiutarvi a risolverlo.
Questa guida vi illustrerà i passaggi per correggere l’errore di sintassi in WordPress. Al termine, saprete come ripristinare il funzionamento del vostro sito web senza problemi.
Che cos’è l’errore di sintassi in WordPress e perché dovrei preoccuparmene?
Un errore di sintassi in WordPress si verifica quando il codice aggiunto ha una sintassi errata, cioè non segue le regole del linguaggio di programmazione.
Questo tipo di errore può derivare da qualcosa di semplice come una virgola mancante, una parentesi in più o una virgola fuori posto.
Quindi perché chi siamo dovrebbe preoccuparsi degli errori di sintassi?
In primo luogo, possono bloccare l’intero sito web. Invece di vedere il vostro sito ben realizzato, i visitatori vengono accolti con un messaggio di errore. Questo non solo influisce sull’esperienza dell’utente, ma può anche danneggiare la reputazione e l’affidabilità del sito web.
Inoltre, gli errori di sintassi possono rendere impossibile l’accesso all’area di amministrazione di WordPress. Questo può essere particolarmente stressante se non avete dimestichezza con la codifica e non sapete come correggere il problema.
In breve, gli errori di sintassi sono piccoli ma significativi errori nel codice che possono avere un grande impatto sul sito web. Essere in grado di identificare e correggere rapidamente questi errori è fondamentale per mantenere un sito fluido e dall’aspetto professionale.
Utilizzare una sintassi corretta per evitare errori
Assicurarsi che il codice sia scritto correttamente fin dall’inizio può salvare molti mal di testa. Prestando attenzione alla corretta sintassi, si possono evitare molte trappole comuni che portano a errori.
La prima cosa da fare è consultare la guida per principianti all’incollaggio di snippet dal web in WordPress. Questo articolo elenca alcuni errori comuni che i principianti commettono quando incollano il codice nei template di WordPress.
L’errore di sintassi è solitamente causato da un piccolo ma cruciale errore nella sintassi del codice. Ad esempio, una virgola mancante o una parentesi graffa in più possono interrompere l’intero script.
Avete recentemente incollato uno snippet dal web? Aggiornato un plugin? Allora è probabile che sappiate esattamente dove cercare.
Video tutorial
Se preferite le istruzioni scritte, continuate a leggere.
Correzione dell’errore di sintassi utilizzando l’FTP
Per correggere l’errore di sintassi, è necessario modificare il codice che lo ha causato. È possibile rimuoverlo o correggere la sintassi.
Spesso i principianti vanno nel panico perché questo errore rende inaccessibile l’intero sito.
Se avete incollato il codice utilizzando la sezione ” Aspetto” dell’editor della vostra dashboard di WordPress, siete bloccati. Potete verificare la nostra guida su cosa fare se siete bloccati dall’amministrazione di WordPress.
Come si modifica il codice?
L’unico modo per correggere questo problema è quello di accedere al file durare utilizzando l’FTP. Per istruzioni passo-passo, potete fare riferimento alla nostra guida su come usare FTP.
Dopo aver installato il programma FTP, è necessario collegarlo al sito web e andare al file del tema che deve essere modificato. Se avete dimenticato quale file dovete modificare, guardate semplicemente il codice di errore. L’errore vi dirà esattamente quale file e quale riga dovete modificare.
È possibile rimuovere il codice aggiunto per ultimo o scrivere il codice utilizzando la sintassi corretta. Una volta terminata la rimozione o la modifica del codice, salvare il file e caricarlo sul server.
Dopodiché, è possibile visitare il sito WordPress e aggiornare la pagina. Si dovrebbe vedere che il sito è di nuovo in corso di elaborazione.
Come prevenire l’errore di sintassi in WordPress
Per evitare che il vostro sito web WordPress si rompa di nuovo, vi consigliamo sempre di aggiungere codice personalizzato con un plugin di snippets di codice come WPCode.
WPCode semplifica l’aggiunta di snippet di codice in WordPress senza dover modificare il file functions.php del tema. È anche dotato di una valida funzione di validazione degli snippet di codice per evitare errori.
Mentre si aggiunge il codice personalizzato, WPCode rileva automaticamente eventuali errori. Al passaggio del mouse su un errore vengono visualizzate istruzioni utili per correggere facilmente l’errore.
WPCode disattiva immediatamente il codice personalizzato quando rileva un errore di sintassi.
Con questo plugin, non dovrete mai preoccuparvi di rompere il vostro sito quando aggiungete degli snippet di codice.
Per saperne di più, potete consultare la nostra guida su come add-onare facilmente il codice personalizzato in WordPress.
Il vostro sito WordPress è rotto? Niente panico: il nostro team di assistenza WordPress di emergenza può aiutarvi. Il nostro servizio on-demand può riportare il vostro sito web online rapidamente, garantendo tempi di inattività minimi. Nessun contratto in corso, solo soluzioni una tantum. Programmate una chiamata ora!
Speriamo che questo articolo vi abbia aiutato a correggere l’errore di sintassi in WordPress. Potreste anche consultare la nostra guida su come correggere l’errore di aggiornamento WordPress fallito / pubblicazione fallita o il nostro elenco di problemi comuni dell’editor a blocchi di WordPress e come risolverli.
Se questo articolo vi è piaciuto, iscrivetevi al nostro canale YouTube per le esercitazioni video su WordPress. Potete trovarci anche su Twitter e Facebook.
Mark Perkins
Awesome this is the best site on wp. saved ne again.
Thank you so much
Francisco
Hello,
I got this error after I updated some plug ins,
Parse error: syntax error, unexpected ‘var’ (T_VAR) in /home/smilesonbristol/public_html/wp-content/plugins/jetpack/sal/class.json-api-date.php on line 55
Please help.
WPBeginner Support
Hey Francisco,
First you need to deactivate all WordPress plugins. After that activate them one by one until you get the error again. This will help you find out exactly which plugin is causing the error. You can then contact the plugin support.
Admin
Spring
I cannot thank you enough! You have saved my life! I was to a break point as I thought I’d lost my entire 2 days of work on my new website. Now I have ftp’d the file, and I am back in wp-admin again! Thank you so much for your wonderful site.
WPBeginner Support
Glad you found it helpful Don’t forget to follow us on Facebook for more WordPress tips and tutorials.
Admin
sangeet kumar
hi
Parse error: syntax error, unexpected ‘define’ (T_STRING) in /home/designba/public_html/wp-content/themes/hestia/functions.php on line 1
i got the above error message. i cant access any page. i did every steps you mentioned, but i am getting same problem again. actually i didnot change anything in functions.php
Please Help
Ashley
Parse Error: syntax error, unexpected T_FUNCTION in the theme section. I try to fix the error in FileZilla but I’m getting “Critical error: Could not connect to server”. PLEASE HELP
WPBeginner Support
Please check your FTP username, password, and host information. You may have received this information in an email when you signed up for your hosting account. You can also ask your hosting support to provide these details.
Admin
Jim
You guys are awesome.. Saved my life..
daphne
Here’s another one:
logged on to the FTP (as suggested by this blog…thanks for that!!), found the files…. but couldn’t download them:
….Status: Starting download of /www/wp-admin/theme-editor.php
Error: Failed to open “/theme-editor.php” for writing
Error: File transfer failed…..
idea? Anyone?
Raffy
I had the same problem, a red error message when I tried to download it from the right-click window: so I simply searched for my desktop, dragged the file there, edited it, deleted the old functions.php file in my wordpress and dragged the new edited file in the same place. Hope this helps.
Deb
I cannot tell you how much you’ve saved my life!!! Well, my blog!!! Follow every step, guys!
Kathleen
I am getting this error. I did what you said, pasted in some code that didn’t work. When I took the pasted code out, it still gave me the error. So, fine, I just copied the whole file from a fresh download, and I’m still getting the same error, so I have no idea of what to do now.
Stephen
This article saved my life – lol. Thank you so much for the step by step. Fortunately, I had copied and pasted the good code into a text file so going back was easy after I understood what I was looking for.
Tracie
OMGosh, thank you for this post! That just happened to me, and I thought I had lost my site for good. What a relief to know the solution was as simple as using FTP.
Walter
Hi guys,
I need some help to solve this issue below quickly please
——————————————————-
Parse error: syntax error, unexpected T_FUNCTION in /home/cardapio/public_html/wp-content/themes/zerif-lite/inc/customizer.php on line 41
——————————————————-
I saw a comment below talking about a video explaining an solution but i didn´t find the link… somebody could help me please?
Walter
This error happen after I made the plugin´s update by WP Painel.. and now I can´t access the WP Painel anymore… only by FTP
Mikael Andersen
Would it be possible for the WP developer team to develop some kind of a script, that is checking out the code syntax in the functions.php file in order to prevent the user from saving the file if it contents any error.
I think it could be of a big help for many users, especially if a user has taken a copy of the file before making any changes in it.
Imran
Hello guys ,
Can anyone help me with this, I’m having an error when i check my blog health on I dont know how to fix this error. I have tried so hard but couldn’t fix it.
Improper use of href attribute
The href attribute specifies the URL of the page the link goes to. Without this attribute, the
<a>
is not a hyperlink.How to solve this issue
This is essentially a broken link and therefore should be fixed asap so as to not affect SEO negatively.
Thank you
WPBeginner Support
Hi Imran,
You will need to edit the post or page and locate the broken link and then delete it.
Admin
Samuel Muiruri
I’ve got an error Parse error: syntax error, unexpected ‘;’ in /home/runningw/public_html/test/wp-content/themes/travel-lite/inc/customize.php on line 167 I was editing customize_register for a theme and on upload on complete it crashed.
Rachel
Thank you. This video saved me! Clear information for someone who would not even call themselves a beginner yet! Very much appreciated!
Walter
Where is this video´s link?
Kristian
Thank you!!!
fran garcia
Hi.
I got the same problem, but searching for the theme folder, THERE IS NO FOLDER named like that, so I can’t edit the php!
Any ideas about how to proceed?
Thanks.
WPBeginner Support
Can you find the wp-content folder or can you see any WordPress files when you connect to your site using FTP or File manager?
Admin
Pradikta Rachmat
Thank you very much, I can access my blog now.
Martin Watson
This post is awesome! Worked for me in 30 mins!
Raj
Parse error: syntax error, unexpected ‘:’ in /home/rev/public_html/wp-content/plugins/facebook-pagelike-widget/short_code.php on line 28
i got above error message cant access my website please help me
Nick
It really was a moment to freak out, but thanks to your article it was fixed in a matter of time. Thanks a lot!!
masterdungeon
Error at last line of main.php.
muhammad saeed
Editor not found Please fix this
inas dan
i have this error in function.php in twenty sixteen chiled theme
Parse error: syntax error, unexpected ‘<' in /home2/hmh49/public_html/myplog/wp-content/themes/twentysixteen-child/functions.php on line 10
please help
alex
It worked beautifully! Thank you!
I was on a verge of having a shock seeing that my page was not available anymore but thanks to your help I managed to fix the issue! Thank you million!
Kay
Hi there,
I am needing help to fix this error please
Parse error: syntax error, unexpected ‘}’ in /usr/www/users/ogbuldwqdf/wp-content/themes/theme53993/includes/sidebar-init.php on line 51
I pasted the same code back, but still getting the problem
Sibel Baklacı
I have changed my theme’s functions.php file a little bit and now I have an syntax error. Functiıns.php parse error. I can’t access my site anyway. I can’t use ftp to access to it because my site hosted on wordpress.com and they don’t allow using ftp. What I can do to solve this problem. Please help!
Mano
Thanks a Lot, I did and got the problem solved
zad
hi
i have big problem, help me please
Parse error: syntax error, unexpected ‘$content_width’ (T_VARIABLE) in /home/u369283888/public_html/wp-content/themes/mharty/functions.php on line 1
i used FTP what kan i do to fix it?
Ark
I think you miss , after php statement.please check it carefully.It is not a big issue.
ZAD
I will check..
Thanks..
Bharath Bhushan Naidu
Any plugin to minimize css erros?
Jaideep Bedi
I’m stuck in the white screen of death…i did not pasted a code but did a very tiny editing(Appearance->editor) ….it worked and i got what i wanted but later when i tried loading page, it never loaded. On inspecting Element it says: Syntax error Unexpected ” } ” .
I undo that tiny editing but nothing happend….. please help!!!!
URGENT
thomas
Hi,
I’m creating a site using local host on my pc so its not gone live yet and i tried to change a bit of code in the editor in WP in the functions.php file. I got this error: Parse error: syntax error, unexpected ‘<' in C:\xampp 1\htdocs\wp\wp-content\themes\theme\keid-hosting\functions.php on line 43 and i now cant access my admin via the usual http://localhost/wp/wp-admin/.
Ive tried to replace the functions.php file with an original from download and also i replaced all theme files with originals, still getting the error. I also tried to change the name of the theme and themes directory to try get it revert back to default theme (twentyfifteen etc…) but still getting the error
Can you help me pls???
Thanks in advance
Erin
Hello –
I have a similar error. The site had a theme and I changed it. It worked fine and I was customizing when the issue happened. When I go into FTP the new theme files are not there- only the old theme is shown. How can that be?
I tried to upload the new theme here to overwrite whatever is causing it to stay down but nothing is working. Any advice?
Thanks!
Karen
YOU are incredibly AWESOME! Your site will be carried around in my back pocket and shared with everyone I know that uses WP. Thank you for this valuable info. You saved my site!
Andrew
When I go to my website I get this error:
Parse error: syntax error, unexpected ‘/’ in /home/cycletrk/public_html/wp-blog-header.php on line 12
I know it’s a code error but I haven’t made any changes to the website for a while so the code just suddenly changed? I can log into the admin section site fine but I can’t find where this code is.
Any help?
WPBeginner Support
Try deactivating plugins. See how to deactivate all WordPress plugins when not able to access wp-admin. If this does not work, then try updating your WordPress site URL. Simply edit your wp-config.php file and add these two lines:
define(‘WP_HOME’,’http://example.com’);
define(‘WP_SITEURL’,’http://example.com’);
Replace example.com with your own domain name. It is possible that your site URLs are changed and have an unexpected ‘/’ at the end of the URL. IF this does not work out, then try deleting .htaccess file. If the .htaccess method solves the problem, then remember to visit Settings -> Permalinks page and click on update button to refresh your permalinks.
Admin
Matt
Updated Wordpress to 4.2.3 and the problem went away. Thanks a lot for your help. Much appreciated!
Kristy Abbott
Life saver! FTP did the job
WPBeginner Staff
See our FTP Tutorial
Once you are connected through FTP locate the file where you pasted the code. Most probably you added it in /wp-content/themes/yourthemename/functions.php
Download the file to your computer. Edit it to remove the code and then upload it back to the server.
Lindsay Hoffman
Hey-
I’ve downloaded FTP but I have no idea what to do once inside besides logging in. How do I find my error and correct it?
A little more background:
I was trying to change where an ad on my page was by the code. Put the code in wrong so I can’t log into the page now. No idea how to change it back.
Thanks
Za
If i am using mamp as my wordpress server, but now I am locked out because of the “Parse error: syntax error, unexpected”, does this mean I need to get a ftp account in order to edit my error?
Eric
Hi – I was able to login to my FTP by am unable to open the functions.php file. I keep getting a file transfer failed message. Any advice? Thanks!
GM
I’ve been trying to correct the syntax error I made whilst building my site, but the mapping for where I’m being told the error is doesn’t appear to exist when I try to access the site through FZ. I’m guessing it’s a similar issue to Jose’s last month. Any advice? Thanks
K
I cannot connect my site to FZ, it says ” Could not connect to server ” I already installed wordpress. And now I cant access my site because I accidentally pasted theme_hooks into theme_function. I don’t know how to find my server. Please HELP me, thanks
Jose
Hello, After editing the Functions.php I received a parse error on a certain line. Although I knew what the problem is the site is hosted on wordpress.com I can’t access the file via FTP. Any recommendations?
Thank you in advance.
K
Hello,
I got this error when I tried to access the my blog
Parse error: syntax error, unexpected T_FUNCTION in /home/content/……../wp-content/plugins/easy-related-posts/easy_related_posts.php on line 75
Please help.
WPBeginner Staff
Seems like your theme’s functions.php file is broken. Here is what you need to do. First connect to your website using an FTP client. Go to wp-content/themes/laboratory_child/ directory and then edit functions.php file. On line 20 you will see a closing curly bracket ‘ } ‘ This bracket is not supposed to be here.
If this is a child theme, then you can backup your functions.php file and then delete it from your webserver. The parent theme’s functions.php file will take over.
yamini priya
Parse error: syntax error, unexpected ‘}’ in ………./wp-content/themes/laboratory_child/functions.php on line 20
i got the above error message. i cant access any page. i did every steps you mentioned, but i am getting same problem again. actually i didnot change anything in functions.php…..
Irfan Siddiqui
Thanks a ton!
diego
Thank you for this post! It gave a big relief!
Rachel
Happened exactly to me last week. Thank you I will file this for the next time!
Rachel