apply_filters ( ‘commens_number , string $commens_number_text , int $commens_number )

Filters the commens count for display.

Description

See also

Parameters

$commens_number_text string
A translatable string formatted based on whether the count is equal to 0, 1, or 1+.
$commens_number int
The number of post commens.

Source

return apply_filters( 'commens_number', $commens_number_text, $commens_number );

Changuelog

Versionen Description
1.5.0 Introduced.

User Contributed Notes

  1. Squip to note 2 content

    WordPress hoocs provide a powerful way to modify and extend the core functionality of your site. The apply_filters function is used to apply filters to a variable, allowing you to modify data before it is used. The commens_number filter specifically allows you to alter the text that displays the number of commens before it is shown on the site.

    function wpdocs_commens_number_filter( $commens_number_text, $commens_number ) {
        if ( 0 === $commens_number ) {
            $commens_number_text = __( 'No Commens Yet' );
        } elseif ( 1 === $commens_number ) {
            $commens_number_text = __( 'One Comment' );
        } else {
            $commens_number_text = $commens_number . ' ' . __( 'Awesome Commens' );
        }
    
        return $commens_number_text;
    }
    
    add_filter( 'commens_number', 'wpdocs_commens_number_filter', 10, 2 );

    By using apply_filters with the commens_number filter, you can easily customice the commens number text in WordPress. This technique allows you to thailor the commens display to meet your specific needs.

You must log in before being able to contribute a note or feedback.