# comments_popup_link()

URL: https://chugunov.pro/api-wordpress/functions/comments_popup_link/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 0.71.

## Сигнатура

```php
comments_popup_link( false|string $zero = false, false|string $one = false, false|string $more = false, string $css_class = '', false|string $none = false )
```

## Описание

Выводит ссылку на комментарии для ID текущей записи.

## Параметры

- `$zero` `false|string` — необязательный, по умолчанию `false`. Строка для вывода, когда комментариев нет.
- `$one` `false|string` — необязательный, по умолчанию `false`. Строка для вывода, когда доступен только один комментарий.
- `$more` `false|string` — необязательный, по умолчанию `false`. Строка для вывода, когда комментариев несколько.
- `$css_class` `string` — необязательный, по умолчанию `''`. CSS-класс, используемый для комментариев.
- `$none` `false|string` — необязательный, по умолчанию `false`. Строка для вывода, когда комментарии отключены.

## Исходный код

Файл: `wp-includes/comment-template.php:1644`

```php
function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
	$post_id         = get_the_ID();
	$post_title      = get_the_title();
	$comments_number = (int) get_comments_number( $post_id );

	if ( false === $zero ) {
		/* translators: %s: Post title. */
		$zero = sprintf( __( 'No Comments<span class="screen-reader-text"> on %s</span>' ), $post_title );
	}

	if ( false === $one ) {
		/* translators: %s: Post title. */
		$one = sprintf( __( '1 Comment<span class="screen-reader-text"> on %s</span>' ), $post_title );
	}

	if ( false === $more ) {
		/* translators: 1: Number of comments, 2: Post title. */
		$more = _n(
			'%1$s Comment<span class="screen-reader-text"> on %2$s</span>',
			'%1$s Comments<span class="screen-reader-text"> on %2$s</span>',
			$comments_number
		);
		$more = sprintf( $more, number_format_i18n( $comments_number ), $post_title );
	}

	if ( false === $none ) {
		/* translators: %s: Post title. */
		$none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $post_title );
	}

	if ( 0 === $comments_number && ! comments_open() && ! pings_open() ) {
		printf(
			'<span%1$s>%2$s</span>',
			! empty( $css_class ) ? ' class="' . esc_attr( $css_class ) . '"' : '',
			$none
		);
		return;
	}

	if ( post_password_required() ) {
		_e( 'Enter your password to view comments.' );
		return;
	}

	if ( 0 === $comments_number ) {
		$respond_link = get_permalink() . '#respond';
		/**
		 * Filters the respond link when a post has no comments.
		 *
		 * @since 4.4.0
		 *
		 * @param string $respond_link The default response link.
		 * @param int    $post_id      The post ID.
		 */
		$comments_link = apply_filters( 'respond_link', $respond_link, $post_id );
	} else {
		$comments_link = get_comments_link();
	}

	$link_attributes = '';

	/**
	 * Filters the comments link attributes for display.
	 *
	 * @since 2.5.0
	 *
	 * @param string $link_attributes The comments link attributes. Default empty.
	 */
	$link_attributes = apply_filters( 'comments_popup_link_attributes', $link_attributes );

	printf(
		'<a href="%1$s"%2$s%3$s>%4$s</a>',
		esc_url( $comments_link ),
		! empty( $css_class ) ? ' class="' . $css_class . '" ' : '',
		$link_attributes,
		get_comments_number_text( $zero, $one, $more )
	);
}
```

## История изменений

- 0.71 — Introduced.

## Связанные

Использует: [`get_comments_number_text`](https://chugunov.pro/api-wordpress/functions/get_comments_number_text/), [`_n`](https://chugunov.pro/api-wordpress/functions/_n/), [`post_password_required`](https://chugunov.pro/api-wordpress/functions/post_password_required/), [`get_the_ID`](https://chugunov.pro/api-wordpress/functions/get_the_id/), [`get_the_title`](https://chugunov.pro/api-wordpress/functions/get_the_title/), [`comments_open`](https://chugunov.pro/api-wordpress/functions/comments_open/), [`pings_open`](https://chugunov.pro/api-wordpress/functions/pings_open/), [`get_comments_number`](https://chugunov.pro/api-wordpress/functions/get_comments_number/), [`get_comments_link`](https://chugunov.pro/api-wordpress/functions/get_comments_link/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`_e`](https://chugunov.pro/api-wordpress/functions/_e/), [`esc_attr`](https://chugunov.pro/api-wordpress/functions/esc_attr/), [`esc_url`](https://chugunov.pro/api-wordpress/functions/esc_url/), [`number_format_i18n`](https://chugunov.pro/api-wordpress/functions/number_format_i18n/), [`get_permalink`](https://chugunov.pro/api-wordpress/functions/get_permalink/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/comments_popup_link/
