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

WordPressで「タイトルを追加」プレースホルダーを置き換える方法

WordPressの生産性を高める優れた方法の1つは、コンテンツエディターをカスタマイズすることです。

例えば、初期設定のプレースホルダーテキスト「タイトルを追加」は、投稿の見出しを追加する場所を示しています。より関連性の高いテキストを表示することで、コンテンツ作成プロセスを大きく変えることができる場合があります。

経験豊富なWordPress開発者として、私たちは小さな調整が効率と構成に大きな影響を与えることを学びました。プレースホルダーテキストのカスタマイザーは、ライティングエクスペリエンスを向上させる、さりげなくも強力な変更のひとつです。

この投稿では、「タイトルを追加」プレースホルダーをコンテンツ戦略に沿ったテキストに簡単に置き換える方法を紹介します。WordPressエディターをさらに使いやすくしましょう!

How to Replace 'Add Title' Text in WordPress

タイトルのプレースホルダー・テキストを置き換えるタイミングと理由

WordPressサイトで新規投稿を作成する際、「タイトルを追加」というプレースホルダーテキストは、投稿者や投稿者に投稿を開始する方法を知らせる便利なプロンプトです。

それはブロックエディターでもクラシックエディターでも同じだ。

Placeholder Text for New Post

しかし、カスタム投稿タイプを使用している場合や、クライアントのためにカスタムCMSを作成している場合は、テキストを一般的でないものに変更した方がユーザーにとって便利な場合があります。

個人プロフィールを作成するためにカスタム投稿タイプを作成し、その人の名前をタイトルとして使用したいとします。プレースホルダーテキストを置き換えることで、ユーザーにこのフィールドを使って名前を入力するように指示できます。

あるいは、映画データベースのカスタム投稿タイプを作成した場合、より有用なプレースホルダーテキストは、’Enter movie name with release year’かもしれません。

ということで、WordPressで「タイトルを追加」テキストを置き換える方法を見てみましょう。

WordPressでタイトルのプレースホルダーを置き換える

WordPressでタイトルのプレースホルダーを置き換えるには、WordPressのテーマファイルにコードを追加する必要があります。サイトへのコードの追加にヘルプが必要な場合は、WordPressにウェブからスニペットを貼り付ける方法についての初心者ガイドを参照してください。

必要なのは、テーマのfunctions.phpファイルにこのコードスニペットを追加するか、無料のWPCodeプラグイン(推奨)を使用してカスタムコードを安全に追加することだけです:

1
2
3
4
5
6
7
8
9
10
11
function wpb_change_title_text( $title ){
     $screen = get_current_screen();
   
     if  ( 'movie' == $screen->post_type ) {
          $title = 'Enter movie name with release year';
     }
   
     return $title;
}
   
add_filter( 'enter_title_here', 'wpb_change_title_text' );
Adding a Code Snippet to WPCode

映画」をカスタム投稿タイプに、「映画名と公開年を入力してください」をカスタムテキストに置き換えることをお忘れなく。

このコードは、ブロックエディターを使用する際に、カスタム投稿タイプ「movie」のプレースホルダーテキストを変更します。

Placeholder Text Replaced in Gutenberg Editor

上のスクリーンショットでは、新しい映画投稿タイプを作成する際に、「タイトルを追加」プレースホルダーが「映画名と公開年を入力」に置き換えられていることに注目してください。

一番良いのは、同じコード・スニペットがクラシックWordPressエディターを使用している場合にも機能することだ。

Placeholder Text Replaced in Classic Editor

このコード・スニペットはどのように機能するのか?

コードを説明しよう。まず、wpb_change_title_text関数を作成しました。関数の中に、ユーザーが特定のカスタム投稿タイプ画面にいるかどうかのチェックを追加しました。

ユーザーがそのカスタム投稿タイプの画面にいることを検出すると、カスタムタイトルテキストを返します。その後、この関数をenter_title_hereフィルターにフックするだけで、初期設定のタイトルテキストを変更できます。

これですべてです。これでカスタム投稿タイプに新規エントリーを作成することができ、タイトルフィールドにカスタムプレースホルダーテキストが表示されます。

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.

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.

アバター

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.

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

6件のコメントLeave a Reply

  1. raju

    Really.. great tutorial. It has helpmed a lot. I have small question. how to change “Title” column to my “custom colomn” in custom post type list and i want to give edit option for that custom column as like “title”. I have been to google about this, it has been found that, by default “Title” comes with “Edit, Trash” etc links. but I want to change “title” to custom column with same edit, trash columns. Thanks in advance.

  2. Max

    This is great.

    I always wondered if this was possible.

    Is there a plugin that can do this?

  3. Mike

    This is pretty easy to fix, nice one.

    I have a quick question regarding the functions.php. I’ve seen people adding functions in separate .php files in their “inc” folder of their theme. To this day I’m unsure on how to link these other files into the functions.php. Any idea?

  4. Daron Spence

    Very nice! I was just contemplating how to do this for a plugin before I went to bed last night. You guys just made my day a lot better! :)

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.