_n()

関数の概要

WordPressの多言語対応に使用される関数であり、単数形と複数形を適切に切り替えるための関数です。

パラメータの説明

  • singular: 単数形のテキスト
  • plural: 複数形のテキスト
  • number: 数値

戻り値

単数形または複数形のテキストを返します。

使用例


echo _n( '1 apple', '%s apples', $number, 'text-domain' );
echo _n( '1 book', '%s books', $number, 'text-domain' );

関連する関数

  • __(): テキストの翻訳を行う関数
  • _x(): テキストの翻訳を行う関数で、コンテキストを指定できる