Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
Coppa WPB
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Come correggere l’errore di sintassi in WordPress

Nota editoriale: guadagniamo una commissione dai link dei partner su WPBeginner. Le commissioni non influenzano le opinioni o le valutazioni dei nostri redattori. Per saperne di più su Processo editoriale.

Vi state chiedendo come correggere l’errore di sintassi in WordPress?

Esistono molti tutorial di WordPress che richiedono l’aggiunta di snippet di codice al sito web. Purtroppo, un piccolo errore può causare la rottura dell’intero sito, il che è molto spaventoso, soprattutto per i nuovi utenti. Se state provando qualcosa di nuovo sul vostro sito WordPress e ricevete il seguente errore “Syntax error, unexpected…”, non fatevi prendere dal panico.

In questo articolo vi mostreremo come correggere l’errore di sintassi inatteso in WordPress.

How to Fix the Syntax Error in WordPress

Utilizzare una sintassi corretta per evitare errori

La prima cosa da fare è consultare la guida per principianti all’incollaggio di snippet dal web in WordPress. Questo articolo elenca alcuni errori molto comuni commessi dai principianti quando incollano il codice nei template di WordPress.

L’errore di sintassi è solitamente causato da un piccolo ma cruciale errore nella sintassi del codice.

Example of a syntax error in WordPress

Ad esempio, potrebbe essere una virgola mancante o una parentesi graffa in più che può interrompere l’intero script.

Avete recentemente incollato uno snippet dal web? Avete aggiornato un plugin? È probabile che sappiate esattamente dove cercare.

Video tutorial

Subscribe to WPBeginner

Se il video non vi piace o avete bisogno di ulteriori istruzioni, continuate a leggere tutto.

Correggi l’errore di sintassi con l’FTP

Per correggere l’errore di sintassi, è necessario modificare il codice che ha causato l’errore. È 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 ” Editor del codice della vostra dashboard di WordPress, siete bloccati. Selezionate 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 è accedere al file che avete modificato per ultimo usando l’FTP. Leggete la nostra guida su come usare l’FTP per istruzioni passo passo.

Dopo aver installato il programma FTP, collegarlo al sito web e accedere al file del tema da modificare. Se si dimentica quale file è necessario modificare, basta guardare 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 con la sintassi corretta. Una volta terminata la rimozione o la modifica del codice, salvare il file e caricarlo sul server.

Dopo di che, visitate il vostro sito WordPress, ricaricate la pagina e vedrete che il vostro 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 plugin

WPCode semplifica l’aggiunta di snippet di codice in WordPress senza dover modificare il file functions.php del tema.

Inoltre, è dotato di una valida funzione di convalida degli snippet di codice che aiuta a prevenire gli errori più comuni.

Mentre si aggiunge il codice personalizzato, WPCode rileva automaticamente eventuali errori. Al passaggio del mouse sull’errore vengono visualizzate le istruzioni utili per correggere facilmente l’errore.

Smart code snippet validation to find code errors

WPCode disattiva immediatamente il codice personalizzato quando rileva un errore di sintassi.

Ora non dovrete più preoccuparvi di rompere il vostro sito con l’aggiunta di snippet di codice.

Error handling in your custom code snippet

Per saperne di più, potete consultare la nostra guida su come add-onare facilmente il codice personalizzato in WordPress.

Speriamo che questo articolo vi abbia aiutato a correggere l’errore di sintassi in WordPress. Potreste anche leggere la nostra guida definitiva per aumentare la velocità di WordPress e la nostra scelta dei migliori editor del codice per Mac e Windows.

Se questo articolo vi è piaciuto, iscrivetevi al nostro canale YouTube per le esercitazioni video su WordPress. Potete trovarci anche su Twitter e Facebook.

Divulgazione: I nostri contenuti sono sostenuti dai lettori. Ciò significa che se cliccate su alcuni dei nostri link, potremmo guadagnare una commissione. Vedi come WPBeginner è finanziato , perché è importante e come puoi sostenerci. Ecco il nostro processo editoriale .

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Il kit di strumenti WordPress definitivo

Ottenete l'accesso gratuito al nostro kit di strumenti - una raccolta di prodotti e risorse relative a WordPress che ogni professionista dovrebbe avere!

Reader Interactions

86 commentiLascia una risposta

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Roberta says

    This is a frustrating error and your tutorial allowed me to fix it in less than 5 minutes. Thank you so much!

  3. Jamie den Haan says

    Hi,

    Can someone please help me out? I keep getting a ‘SyntaxError: JSON Parse error: Unexpected identifier ”Error” when i want to check out on my website. I don’t know what to do and nobody can place an order!!

    Thanks a lot,

    Jamie

  4. Aaron says

    I get “critical error: could not connect to server” when I enter my server information. So I can’t even get to the point that your video begins at.

  5. Raffy says

    Thank you SO SO much! The bad snippet was invisible inside the Admin page in WordPress, for some reason, but fully visible in the functions.php found in the FTP!!

    You saved my day, thank you very much again!

  6. Kim martin says

    Thank you SO much! 7 days of getting My hosting service(a very large popular one) to try to fix this no luck just trying to upsell me on things I neither want nor need.

    Me thinking okay a whole new website and i found this, I just actually deleted the whole plugin(elementor) Whoo Hoo!

  7. Micah says

    Hello:

    I have run into this error helping someone else out with their website, so I wasn’t using my actual website when I got this error. I’m wondering how I can remove the error when I’m working on someone else’s site? I have their wordpress. org login information, but obviously I’m locked out of everything now. Any guidance would be appreciated.

  8. Tamia says

    Thanks for this tutorial. I had a parsing/syntax problem when editing functions.php in a new website. I was working on the admin page of my WordPress site when I attempted to comment-out a line of code (using instructions by the theme author) but that caused the error. I had copied the functions.php code to TextWrangler, made the alteration, and pasted the whole doc back into the edit window. In “updating” the page I got the error and was effectively locked out of the site. So I used FTP to upload and overwrite the relevant doc, using a backup I’d made the previous day (thank goodness for those). If it hadn’t been for WP Beginner’s clear instructions here and on the “What To Do When You Are Locked Out of WordPress Admin (wp-admin)” post, I’d have been tearing my hair out. Thanks!

  9. Tom Delano says

    In trying to log into my page via Filezilla, am I supposed to use my admin account or my WordPress account? I’ve tried both and the password authentication keeps failing. I have my original admin password and it’s worked consistently since I’ve had the website up.

    • WPBeginner Support says

      Hey Tom,

      You’ll need to use your FTP username and password. You will find it in the email you received from your web hosting company when you first signed up. You can also find this information under your cPanel dashboard.

      Admin

  10. Justine says

    I urgently need help. CO-editor on my site (which is supposed to launch tomorrow) tried to change code to change our profile pictures. Something went horribly wrong and we locked out of our site. Get this error: Parse error: syntax error, unexpected ‘add_filter’ (T_STRING) in

  11. Monica says

    Re: my last comment, I deactivated the plugin and the error went away. So you won’t see what I was describing anymore. I just decided to not use it than try to spend all night figuring out the problem.

  12. Monica says

    I am getting parse error syntax errors on all my product pages. This was brought to my attention by someone trying to shop my site. I have not made any edits to the code, installed any new plugins, or accessed the site at all in months. Not sure when this started but I haven’t had an order in few weeks. If I didn’t add or edit anything to cause this how do I know what to fix? All the error messages reference line 1 of the php file but all there is on line 1 is <?php. It's on all product pages. Here is just one example:

  13. shazwan says

    Hi,

    I’m managing a website for my society and its has been long since the last time everyone actually had logged into the hosting account and we kind of lost the log in credentials and didn’t even know what hosting we’re using because they paid years ahead before. And maybe changed providers. But I know that our domain is from Godaddy and checked, but the hosting isn’t from the same provider.

    It may take some time as we dig through the emails, is there any way to fix syntax error other than through FTP?

  14. Patrick says

    Hi. I tried uploading a theme though Filezila since WordPress was having issues trying to upload the theme and now I’m locked up and I get these two lines

    Please Help!!! Thank you!

Rispondi a stanley Annulla risposta

Grazie per aver scelto di lasciare un commento. Tenga presente che tutti i commenti sono moderati in base alle nostre politica dei commenti e il suo indirizzo e-mail NON sarà pubblicato. Si prega di NON utilizzare parole chiave nel campo del nome. Avremo una conversazione personale e significativa.