Filter hook 'ngettext'

in WP Core File wp-includes/l10n.php at line 498

View Source

ngettext

Filter Hook
Description
Filters the singular or plural form of a string.

Hook Information

File Location wp-includes/l10n.php View on GitHub
Hook Type Filter
Line Number 498

Hook Parameters

Type Name Description
string $translation Translated text.
string $single The text to be used if the number is singular.
string $plural The text to be used if the number is plural.
int $number The number to compare against to use either the singular or plural form.
string $domain Text domain. Unique identifier for retrieving translated strings.

Usage Examples

Basic Usage
<?php
// Hook into ngettext
add_filter('ngettext', 'my_custom_filter', 10, 5);

function my_custom_filter($translation, $single, $plural, $number, $domain) {
    // Your custom filtering logic here
    return $translation;
}

Source Code Context

wp-includes/l10n.php:498 - How this hook is used in WordPress core
<?php
 493  	 * @param string $single      The text to be used if the number is singular.
 494  	 * @param string $plural      The text to be used if the number is plural.
 495  	 * @param int    $number      The number to compare against to use either the singular or plural form.
 496  	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
 497  	 */
 498  	$translation = apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain );
 499  
 500  	/**
 501  	 * Filters the singular or plural form of a string for a domain.
 502  	 *
 503  	 * The dynamic portion of the hook name, `$domain`, refers to the text domain.

PHP Documentation

<?php
/**
	 * Filters the singular or plural form of a string.
	 *
	 * @since 2.2.0
	 *
	 * @param string $translation Translated text.
	 * @param string $single      The text to be used if the number is singular.
	 * @param string $plural      The text to be used if the number is plural.
	 * @param int    $number      The number to compare against to use either the singular or plural form.
	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 5
  • File: wp-includes/l10n.php
Related Hooks

Related hooks will be displayed here in future updates.