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

Jak naprawiono błąd składni w WordPressie

Błędy składni w WordPressie mogą wydawać się przytłaczające, zwłaszcza jeśli dopiero zaczynasz kodować.

Możesz napotkać ten problem podczas dodawania fragmentów kodu z poradników. Nawet najmniejszy błąd może zepsuć całą twoją witrynę.

Jeśli widziałeś przerażający komunikat “Błąd składni, nieoczekiwany…”, nie ma powodu do paniki – trafiłeś we właściwe miejsce! Napotkaliśmy i naprawiliśmy ten błąd wiele razy na naszych witrynach internetowych i wiemy, jak pomóc w jego rozwiązaniu.

Ten przewodnik przeprowadzi Cię przez kroki, aby poprawić błąd składni w WordPress. Pod koniec będziesz wiedział, jak przywrócić twoją witrynę internetową do działania.

How to Fix the Syntax Error in WordPress

Co to jest błąd składni w WordPress i dlaczego powinienem się nim przejmować?

Błąd składni w WordPress występuje, gdy dodany kod ma nieprawidłową składnię, co oznacza, że nie jest zgodny z regułami języka programowania.

Ten rodzaj błędu może wynikać z czegoś tak prostego, jak brakujący przecinek, dodatkowy nawias lub niewłaściwie umieszczony cudzysłów.

Dlaczego więc powinieneś przejmować się błędami składni?

Po pierwsze, mogą one spowodować zatrzymanie całej twojej witryny internetowej. Zamiast zobaczyć twoją 111111 pięknie wykonaną witrynę, odwiedzający są witani komunikatem o błędzie. Ma to wpływ nie tylko na wrażenia użytkownika, ale może również zaszkodzić reputacji i niezawodności twojej witryny internetowej.

Ponadto błędy składni mogą uniemożliwić ci dostęp do obszaru administracyjnego WordPress. Może to być szczególnie stresujące, jeśli nie czujesz się komfortowo z kodowaniem i nie wiesz, jak poprawić problem.

Krótko mówiąc, błędy składni to małe, ale znaczące błędy w twoim kodzie, które mogą mieć duży wpływ na twoją witrynę internetową. Zdolność do szybkiej identyfikacji i poprawki tych błędów jest kluczem do utrzymania płynnej i profesjonalnie wyglądającej witryny.

Używanie poprawnej składni w celu uniknięcia błędów

Upewnienie się, że twój kod jest poprawnie napisany od samego początku, może zaoszczędzić ci wielu bólów głowy. Zwracając uwagę na poprawną składnię, można uniknąć wielu typowych pułapek, które prowadzą do błędów.

Pierwszą rzeczą, którą powinieneś zrobić, jest zapoznanie się z przewodnikiem dla początkujących na temat wklejania fragmentów kodu z sieci do WordPressa. W tym artykule wymieniono kilka typowych błędów popełnianych przez początkujących podczas wklejania kodu do szablonów WordPress.

Example of a syntax error in WordPress

Błąd składni jest zwykle spowodowany drobnym, ale kluczowym błędem w składni twojego kodu. Na przykład, brakujący przecinek lub dodatkowy nawias klamrowy może zepsuć cały skrypt.

Czy ostatnio wkleiłeś fragment kodu z sieci? Zaktualizowałeś wtyczkę? W takim razie prawdopodobnie wiesz dokładnie, gdzie szukać.

Film instruktażowy

Subscribe to WPBeginner

Jeśli wolisz pisemne instrukcje, czytaj dalej.

Poprawka błędu składni przy użyciu protokołu FTP

Aby poprawić błąd składni, należy edytować kod, który go spowodował. Można go usuwać lub poprawiać składnię.

Często początkujący użytkownicy wpadają w panikę, ponieważ błąd ten sprawia, że cała ich witryna staje się niedostępna.

Jeśli wkleiłeś kod za pomocą sekcji Wygląd ” Edytor na twoim kokpicie WordPress, to jesteś zablokowany. Możesz sprawdzić nasz przewodnik na temat tego, co zrobić, jeśli jesteś zablokowany w panelu administracyjnym WordPress.

Jak więc edytować kod?

Jedynym sposobem na poprawienie tej sytuacji jest uzyskanie dostępu do ostatnio edytowanego pliku za pomocą FTP. Instrukcje krok po kroku można znaleźć w naszym przewodniku na temat korzystania z FTP.

Po zainstalowaniu programu FTP należy połączyć go z twoją witryną internetową i przejść do pliku motywu, który wymaga edycji. Jeśli nie pamiętasz, który plik musisz edytować, po prostu spójrz na kod błędu. Błąd wskaże dokładnie, który plik i wiersz należy edytować.

Możesz usuwać ostatnio dodany kod lub napisać kod przy użyciu poprawnej składni. Po zakończeniu usuwania lub edytowania kodu zapisz plik i prześlij go z powrotem na twój serwer.

Następnie możesz przejść na twoją witrynę WordPress i odświeżyć stronę. Powinieneś zobaczyć, że twoja witryna znów działa.

Jak zapobiec błędowi składni w WordPress?

Aby zapobiec ponownemu uszkodzeniu twojej witryny internetowej WordPress, zawsze zalecamy dodanie własnego kodu za pomocą fragmentu kodu wtyczki, takiej jak WPCode.

WPCode's homepage

WPCode ułatwia dodawanie fragmentów kodu w WordPressie bez konieczności edytowania pliku functions.php twojego motywu . Jest również wyposażony w inteligentną walidację fragmentów kodu, aby zapobiec błędom.

Podczas dodawania twojego własnego konfiguratora, WPCode automatycznie wykryje wszelkie błędy. Najechanie kursorem na błąd spowoduje wyświetlenie pomocnych instrukcji, dzięki którym łatwo poprawisz swój błąd.

Smart code snippet validation to find code errors

WPCode będzie również natychmiast wyłączać twój własny kod, gdy wykryje błąd składni.

Dzięki tej wtyczce nigdy nie będziesz musiał martwić się o zepsucie twojej witryny podczas dodawania fragmentów kodu.

Error handling in your custom code snippet

Możesz dowiedzieć się więcej w naszym przewodniku na temat łatwego dodawania własnego kodu w WordPress.

Twoja witryna WordPress uległa awarii? Nie panikuj – nasz zespół awaryjnej pomocy technicznej WordPress może ci pomóc. Nasza usługa na żądanie może szybko przywrócić twoją witrynę internetową do trybu online, zapewniając minimalny czas przestoju. Brak bieżących umów, tylko jednorazowe rozwiązania. Zaplanuj połączenie już teraz!

Mamy nadzieję, że ten artykuł pomógł ci poprawić błąd składni w WordPress. Możesz również zapoznać się z naszym przewodnikiem na temat tego , jak poprawić błąd nieudanej aktualizacji / publikacji WordPress lub naszą listą typowych problemów z edytorem bloków WordPress i jak je poprawić.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

85 komentarzyLeave a Reply

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

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

  3. 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!

  4. 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!

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

  6. 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!

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

    • 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

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

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

  10. 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:

  11. 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?

  12. 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!

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

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

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

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

    • 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

  17. 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?

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

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

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

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

  21. 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?

    • 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

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

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

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

  25. Thank you. This video saved me! Clear information for someone who would not even call themselves a beginner yet! Very much appreciated!

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

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

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

  29. 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!

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

  31. 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!

  32. 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?

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

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.