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

WordPressの構文エラーを修正する方法

WordPressの構文エラーは、特にコーディングに慣れていない場合、圧倒されることがあります。

チュートリアルからコード・スニペットを追加するときに、この問題に遭遇するかもしれない。 小さなミスでもサイト全体を壊してしまう可能性があります。

構文エラー、予期しない…」という恐ろしいメッセージを見たことがあっても、慌てる必要はありません!私たちはこのエラーに何度も遭遇し、解決してきました。

このガイドでは、WordPressの構文エラーを修正する手順を説明します。最後には、サイトをスムーズに復旧させる方法がわかるでしょう。

How to Fix the Syntax Error in WordPress

WordPressの構文エラーとは何か?

WordPressの構文エラーは、追加したコードの構文が正しくない、つまりプログラミング言語のルールに従っていない場合に発生します。

この種のエラーは、コンマの抜け、余分な括弧、引用符の位置の間違いなど、単純なことで起こり得る。

では、なぜ構文エラーを気にする必要があるのか?

まず、サイト全体が停止してしまう可能性があります。美しく作られたサイトが表示される代わりに、訪問者はエラーメッセージで迎えられます。これはユーザーエクスペリエンスに影響を与えるだけでなく、サイトの評判や信頼性にも悪影響を及ぼしかねません。

さらに、構文エラーによってWordPressの管理エリアにアクセスできなくなることもあります。コーディングが苦手で、問題の解決方法がわからない場合は、特にストレスになります。

つまり、シンタックスエラーとは、コードの中にある小さいけれども重大なミスのことで、サイトに大きな影響を与える可能性があります。これらのエラーを素早く特定し、修正できることが、スムーズでプロフェッショナルなサイトを維持するための鍵となります。

エラーを避けるために正しい構文を使う

あなたのコードが最初から正しく書かれていることを確認することは、多くの頭痛の種を避けることができます。適切な構文に注意を払うことで、エラーにつながる多くの一般的な落とし穴を避けることができます。

まず最初にすべきことは、WordPressにウェブからスニペットを貼り付けるための初心者向けガイドを見ることです。この投稿では、WordPressテンプレートにコードを貼り付ける際に初心者が犯しがちな間違いをいくつか挙げています。

Example of a syntax error in WordPress

構文エラーは通常、コードの構文におけるわずかな、しかし重大なミスが原因です。例えば、カンマが抜けていたり、中カッコが余分にあったりすると、スクリプト全体が壊れてしまうことがある。

最近、ウェブからスニペットを貼り付けましたか?プラグインを更新しましたか?それなら、どこを見ればいいのかよくご存知でしょう。

動画チュートリアル

Subscribe to WPBeginner

文章での説明がお好きな方は、このまま読み進めてください。

FTPを使用した構文エラーの修正

構文エラーを修正するには、その原因となったコードを編集する必要があります。削除するか、構文を修正するかのどちらかです。

このエラーによってサイト全体がアクセス不能になるため、初心者はしばしばパニックに陥る。

WordPressダッシュボードの外観 ” エディターセクションを使用してコードを貼り付けた場合は、ロックアウトされています。WordPressの管理画面からロックアウトされた場合の対処法をご覧ください。

では、どうやってコードを編集するのか?

これを解決する唯一の方法は、FTPを使って最後に編集したファイルにアクセスすることです。ステップバイステップの手順については、FTPの使い方のガイドを参照してください。

FTPプログラムをインストーラした後、サイトに接続し、編集が必要なテーマファイルにアクセスしてください。編集が必要なファイルを忘れてしまった場合は、エラーコードを見てください。エラーは、あなたが編集する必要があるファイルと行を正確に教えてくれます。

最後に追加したコードを削除するか、正しい構文を使用してコードを記述します。コードの削除や編集が終わったら、ファイルを保存してサーバーにアップロードしてください。

その後、WordPressサイトにアクセスしてページを更新してください。サイトが再び機能していることが確認できるはずです。

WordPressで構文エラーを防ぐ方法

WordPressサイトが再び壊れないようにするには、WPCodeのようなコードスニペットプラグインでカスタムコードを追加することをお勧めします。

WPCode's homepage

WPCodeは、テーマのfunctions.phpファイルを編集することなく、WordPressにコードスニペットを簡単に追加することができます。また、エラーを防ぐためのスマートコードスニペット検証が付属しています。

カスタマイザーコードを追加すると、WPCodeは自動的にエラーを検出します。エラーの上にマウスオーバーすると、役立つ説明が表示されますので、簡単に間違いを修正することができます。

Smart code snippet validation to find code errors

WPCodeはまた、構文エラーを検出した場合、カスタムコードを直ちに無効化します。

このプラグインを使えば、コードスニペットを追加する際にサイトが壊れる心配はない。

Error handling in your custom code snippet

さらに詳しくは、WordPressでカスタムコードを簡単に追加する方法をご覧ください。

WordPress サイトが壊れてしまいましたか?慌てないでください – 緊急 WordPress サポートチームがお手伝いします。当社のオンデマンドサービスなら、ダウンタイムを最小限に抑えながら、お客様のサイトを迅速にオンラインに戻すことができます。継続的な契約は必要ありません。今すぐお電話ください!

この投稿がWordPressの構文エラーの修正にお役に立てば幸いです。WordPressの更新に失敗した/公開に失敗したエラーの修正方法や、WordPressのブロックエディターでよくある問題とその修正方法のリストもご覧ください。

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.

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

アバター

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.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

85件のコメント返信を残す

  1. Roberta

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

  2. Jamie den Haan

    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

  3. Aaron

    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.

    • WPBeginner Support

      Hi Aaron,

      You can also connect to your server using File Manager app in your hosting account dashboard.

      管理者

  4. Daryl

    You’re amazing. Thank you for these videos.

  5. Raffy

    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

    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

    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

    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!

    • WPBeginner Support

      Hi Tamia,

      We are glad you found WPBeginner article helpful :) Don’t forget to follow us on Facebook for more WordPress tips and tutorials.

      管理者

  9. stanley

    Thanks for saving my website from errors

  10. Tom Delano

    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

      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.

      管理者

  11. chris

    thank you so much! you saved me

  12. Justine

    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

  13. Giacomo Lawrance

    Thank you so much! You really saved me there. So grateful of this awesome site, thanks again!

  14. Sara

    You saved my life!
    Thank you so much! :)

  15. Monica

    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.

  16. Monica

    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:

  17. shazwan

    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?

    • WPBeginner Support

      Hi shazwan,

      Unfortunately there is no way around it. There are online tools that will help you figure out where you website is hosted.

      管理者

  18. Patrick

    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!

    • WPBeginner Support

      Hi Patrick,

      Seems like upload was interrupted. Please try uploading the theme files again.

      管理者

  19. Mark Perkins

    Awesome this is the best site on wp. saved ne again.

    Thank you so much

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

      管理者

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

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

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

      管理者

  24. Jim

    You guys are awesome.. Saved my life..

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

  26. Deb

    I cannot tell you how much you’ve saved my life!!! Well, my blog!!! Follow every step, guys!

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

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

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

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

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

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

      管理者

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

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

  35. Kristian

    Thank you!!!

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

      管理者

  37. Pradikta Rachmat

    Thank you very much, I can access my blog now.

  38. Martin Watson

    This post is awesome! Worked for me in 30 mins!

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

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

  41. masterdungeon

    Error at last line of main.php.

  42. muhammad saeed

    Editor not found Please fix this

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

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

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

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

  47. Mano

    Thanks a Lot, I did and got the problem solved

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

  49. Bharath Bhushan Naidu

    Any plugin to minimize css erros?

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

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。