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テーマで編集するファイルを見つける方法

編集メモ: WPBeginner のパートナーリンクから手数料を得ています。手数料は編集者の意見や評価に影響を与えません。編集プロセスについて詳しく知る。

WordPressテーマで編集するファイルの探し方についてよく質問を受けます。

WordPressテーマはいくつかの異なるファイルで構成されています。テーマを変更するためにどのファイルを編集すればいいのか、初心者にはわかりにくいこともあるでしょう。

この投稿では、WordPressテーマのどのファイルを編集すべきかを簡単かつ素早く見つける方法を紹介する。

Finding which WordPress theme file to edit

WordPressテーマのテンプレートファイルを理解する

WordPressテーマはいくつかのファイルで構成されています。テンプレートファイル、カスタムのテンプレートタグや関数、テンプレートパーツ、画像、JavaScript、CSSファイルなどです。

WordPressのトップテーマはすべて、公式のベストプラクティスに従っています。これは、すべてのコードを整理するために標準的なファイルとテンプレート構造を使用していることを意味します。

例えば、WordPressテーマにはすべてarchive.php、single.php、functions.phpなどのファイルがあります。

これらのファイルはそれぞれ、WordPressサイトの特定のエリアを表示するためのテンプレートとして使用されます。例えば、single.phpは個別投稿を表示するために使用され、page.phpテンプレートは単一ページを表示するために使用されます。

WordPressのテンプレート階層を理解することで、WordPressの仕組みをより深く理解することができます。

WordPressテーマにコードを追加する必要がある場合、どのファイルを編集する必要があるかを把握するのにも役立つ。

詳しくは、初心者のためのWordPressテンプレート階層完全チートシートをご覧ください。

ということで、WordPressテーマで編集するファイルを簡単に見つける方法を見てみましょう。

WordPressテーマで編集するテンプレートファイルを探す

まず最初に、What The Fileプラグインをインストールして有効化します。詳しくは、WordPressプラグインのインストール方法のステップバイステップガイドをご覧ください。

プラグインは箱から出してすぐに使えるし、設定することもない。

有効化した後、フロントエンドのWordPress管理バーに「What The File」メニューが表示されます。

What the file menu

あとはメニュー項目にマウスオーバーするだけで、このページを表示するために使用されているテンプレートファイルをリストアップしたドロップダウンメニューが表示される。

ファイル名をクリックすると、WordPress初期設定のファイルエディターが表示され、そのファイルを編集することができます。

WordPress theme file editor

しかし、WordPressファイルエディターを使ってテーマファイルを編集することはお勧めしません。元に戻す設定がないからです。

誤ってサイトからロックアウトしてしまった場合、FTPクライアントを使用して修正する必要があります。そのため、FTPクライアントまたはWordPressホスティングコントロールパネルのファイルマネージャーアプリを使用することをお勧めします。

テーマファイルはメモ帳のようなプレーンテキストエディターで編集できます。

WordPressのテーマに直接変更を加えるのも、良くない考えです。テーマを更新すると、その変更は消えてしまいます。

CSSを追加するだけなら、WordPressのカスタムCSSとして追加できる。それ以外のテーマファイルの変更はすべて、子テーマを作成してください。

What The Fileプラグイン」は、子テーマにコピーして編集する必要があるテーマファイルを探すのに役立ちます。

注意:このプラグインによって管理バーに追加されたメニュー項目は、ログイン中のユーザーすべてに表示され、外部サイトへのリンクを持ちます。このプラグインはステージングサイトなどの開発環境でのみ使用してください。

この投稿が、WordPressテーマで編集すべきファイルを見つけるのにお役に立てば幸いです。

WordPressテーマ開発チートシートやWordPressで生成されたCSSクラスもご覧ください。

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$編集プロセスをご覧ください。

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.

究極のWordPressツールキット

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

Reader Interactions

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

  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. Moinuddin Waheed says

    This is a bit developer oriented task but yes at times we get into the question to edit the file and get into dilemma of which one to edit to get the desired changes made.
    I used to think that it is always the functions.php file that is to be changed but no the change is to be made where it is desired.
    I will explore the plugin to see where we would need to make the edit and changes.
    Thanks for this tutorial guide. it is really helpful understanding these concepts better.

  3. Jiří Vaněk says

    Thank you for the tip. Sometimes, I need to make a change on a website, and one doesn’t immediately know which file to edit. This plugin can be a great helper in figuring out which template file is currently being used.

  4. Riyaz says

    Installing this plugin made my life easier. However, some of the themes just leave something like these:

    $has_sidebar = is_active_sidebar( ‘single-blog’ );
    do_action( ‘mytheme_page_header’ );

    and even some functions which I can find nowhere:
    mytheme_get_listings_image(‘mytheme-list’)

    Is there any way to find these things ?

    • WPBeginner Support says

      You would need to manually go through the files manually, normally those would be found in the functions.php file

      管理者

  5. mark Swift says

    Hi,
    nice article,
    but what if the files are not available in child theme which I have to edit ??

  6. Cos says

    If you copy template (.php) files to your child theme (so you can edit them and not lose your changes when the theme is updated) then what happens if the file you copied and edited is updated by the theme developer? Do you then lose the benefit of their update?

  7. Bond Shands says

    I had hoped to use these directions to change the Post Office Mailing Address line at the bottom of my blog. However, installing and activating the What The File plugin produced no discernible results. Nothing new appeared on my Menu Bar. Also, to be honest, your instructions left me in the dark about how I would see the plugin displayed when viewing the blog page I wished to see. (Also, I’m already a subscriber via an alternate email address).

    • WPBeginner Support says

      Hi Bond Shands,

      Each WordPress site uses a couple of templates which are loaded on each page. For example, the header and footer templates. In order to change your postal address you will need to edit the footer.php file. However, make sure that you backup your WordPress theme before making any direct changes.

      Thanks

      管理者

返信を残す

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