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

Wie man den Syntaxfehler in WordPress behebt

Hinweis der Redaktion: Wir erhalten eine Provision für Partnerlinks auf WPBeginner. Die Provisionen haben keinen Einfluss auf die Meinung oder Bewertung unserer Redakteure. Erfahre mehr über Redaktioneller Prozess.

Fragen Sie sich, wie Sie den Syntaxfehler in WordPress beheben können?

Es gibt so viele WordPress-Tutorials, bei denen Sie Code-Snippets zu Ihrer Website hinzufügen müssen. Leider kann ein kleiner Fehler dazu führen, dass die gesamte Website nicht mehr funktioniert, was vor allem für neue Benutzer sehr beängstigend ist. Wenn Sie etwas Neues auf Ihrer WordPress-Website ausprobieren und die folgende Fehlermeldung erhalten „Syntaxfehler, unerwartet…“, dann geraten Sie nicht in Panik.

In diesem Artikel zeigen wir Ihnen, wie Sie den unerwarteten Syntaxfehler in WordPress beheben können.

How to Fix the Syntax Error in WordPress

Richtige Syntax zur Vermeidung von Fehlern

Als Erstes sollten Sie sich den Leitfaden für Anfänger zum Einfügen von Snippets aus dem Internet in WordPress ansehen. Dieser Artikel listet einige sehr häufige Fehler auf, die von Anfängern beim Einfügen von Code in WordPress-Vorlagen gemacht werden.

Der Syntaxfehler wird in der Regel durch einen kleinen, aber entscheidenden Fehler in Ihrer Codesyntax verursacht.

Example of a syntax error in WordPress

So kann beispielsweise ein fehlendes Komma oder eine zusätzliche geschweifte Klammer das gesamte Skript unterbrechen.

Haben Sie kürzlich ein Snippet aus dem Web eingefügt? Ein Plugin aktualisiert? Dann wissen Sie wahrscheinlich genau, wo Sie suchen müssen.

Video-Anleitung

Subscribe to WPBeginner

Wenn Ihnen das Video nicht gefällt oder Sie weitere Anweisungen benötigen, lesen Sie bitte weiter.

Behebung des Syntaxfehlers mit FTP

Um den Syntaxfehler zu beheben, müssen Sie den Code bearbeiten, der diesen Fehler verursacht hat. Sie können ihn entweder entfernen oder die Syntax korrigieren.

Oft geraten Anfänger in Panik, weil dieser Fehler dazu führt, dass Ihre gesamte Website nicht mehr zugänglich ist. Wenn Sie den Code über das WordPress-Dashboard im Bereich Erscheinungsbild “ Editor eingefügt haben, sind Sie ausgesperrt. Sehen Sie sich unseren Leitfaden an, was zu tun ist, wenn Sie aus dem WordPress-Admin ausgesperrt sind.

Wie kann man den Code bearbeiten?

Die einzige Möglichkeit, dieses Problem zu beheben, ist der Zugriff auf die zuletzt bearbeitete Datei per FTP. Lesen Sie unsere Anleitung zur Verwendung von FTP für eine schrittweise Anleitung.

Nachdem Sie das FTP-Programm installiert haben, verbinden Sie es mit Ihrer Website und gehen Sie zu der Themadatei, die bearbeitet werden muss. Falls Sie vergessen haben, welche Datei Sie bearbeiten müssen, sehen Sie sich einfach den Fehlercode an. Der Fehler sagt Ihnen genau, welche Datei und welche Zeile Sie bearbeiten müssen.

Sie können entweder den zuletzt hinzugefügten Code entfernen oder den Code in der richtigen Syntax schreiben. Wenn Sie mit dem Entfernen oder Bearbeiten des Codes fertig sind, speichern Sie die Datei und laden Sie sie wieder auf Ihren Server hoch.

Besuchen Sie danach Ihre WordPress-Site, aktualisieren Sie die Seite, und Sie sollten sehen, dass Ihre Site wieder funktioniert.

Wie man den Syntaxfehler in WordPress verhindert

Um zu verhindern, dass Ihre WordPress-Website wieder kaputt geht, empfehlen wir immer, benutzerdefinierten Code mit einem Code-Snippets-Plugin wie WPCode hinzuzufügen.

WPCode plugin

MitWPCode können Sie ganz einfach Codeschnipsel in WordPress hinzufügen, ohne die functions.php-Datei Ihres Themes bearbeiten zu müssen.

Außerdem verfügt es über eine intelligente Code-Snippet-Validierung, mit der Sie häufige Code-Fehler vermeiden können.

Während Sie Ihren benutzerdefinierten Code hinzufügen, erkennt WPCode automatisch alle Fehler. Wenn Sie den Mauszeiger über den Fehler bewegen, werden hilfreiche Anweisungen angezeigt, sodass Sie Ihren Fehler leicht korrigieren können.

Smart code snippet validation to find code errors

WPCode deaktiviert Ihren benutzerdefinierten Code auch sofort, wenn es einen Syntaxfehler feststellt.

Jetzt müssen Sie sich keine Sorgen mehr machen, dass Ihre Website beim Hinzufügen von Codefragmenten beschädigt wird.

Error handling in your custom code snippet

Weitere Informationen finden Sie in unserer Anleitung zum einfachen Hinzufügen von benutzerdefiniertem Code in WordPress.

Wir hoffen, dass dieser Artikel Ihnen geholfen hat, den Syntaxfehler in WordPress zu beheben. Vielleicht interessieren Sie sich auch für unseren ultimativen Leitfaden zur Steigerung der WordPress-Geschwindigkeit und unsere Expertenauswahl der besten Code-Editoren für Mac und Windows.

Wenn Ihnen dieser Artikel gefallen hat, dann abonnieren Sie bitte unseren YouTube-Kanal für WordPress-Videotutorials. Sie können uns auch auf Twitter und Facebook finden.

Offenlegung: Unsere Inhalte werden von unseren Lesern unterstützt. Das bedeutet, dass wir möglicherweise eine Provision verdienen, wenn Sie auf einige unserer Links klicken. Mehr dazu erfahren Sie unter Wie WPBeginner finanziert wird , warum das wichtig ist und wie Sie uns unterstützen können. Hier finden Sie unseren redaktionellen Prozess .

Das ultimative WordPress Toolkit

Erhalte KOSTENLOSEN Zugang zu unserem Toolkit - eine Sammlung von WordPress-bezogenen Produkten und Ressourcen, die jeder Profi haben sollte!

Reader Interactions

86 KommentareEine Antwort hinterlassen

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

    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.

  3. Spring says

    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.

  4. sangeet kumar says

    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

  5. Ashley says

    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 says

      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

  6. daphne says

    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 says

      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.

  7. Kathleen says

    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.

  8. Stephen says

    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.

  9. Tracie says

    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.

  10. Walter says

    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 says

      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

  11. Mikael Andersen says

    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.

  12. Imran says

    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

  13. Samuel Muiruri says

    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.

  14. Rachel says

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

  15. fran garcia says

    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.

  16. Raj says

    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

  17. Nick says

    It really was a moment to freak out, but thanks to your article it was fixed in a matter of time. Thanks a lot!!

  18. inas dan says

    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

  19. alex says

    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!

  20. Kay says

    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

  21. Sibel Baklacı says

    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!

  22. zad says

    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?

  23. Jaideep Bedi says

    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

  24. thomas says

    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

  25. Erin says

    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!

  26. Karen says

    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!

  27. Andrew says

    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 says

      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

  28. WPBeginner Staff says

    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.

  29. Lindsay Hoffman says

    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

  30. Za says

    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?

  31. Eric says

    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!

  32. GM says

    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

  33. K says

    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

  34. Jose says

    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.

  35. K says

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

  36. WPBeginner Staff says

    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.

  37. yamini priya says

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

Eine Antwort hinterlassen

Danke, dass du einen Kommentar hinterlassen möchtest. Bitte beachte, dass alle Kommentare nach unseren kommentarpolitik moderiert werden und deine E-Mail-Adresse NICHT veröffentlicht wird. Bitte verwende KEINE Schlüsselwörter im Namensfeld. Lass uns ein persönliches und sinnvolles Gespräch führen.