post_comment_count
Filters the value of a specific post field for display.
Only applied to post fields name which is not prefixed with post_.
- post_ID
- post_comment_status
- post_ping_status
- post_to_ping
- post_pinged
- post_guid
- post_menu_order
- post_comment_count
Это один из вариантов динамического хука post_(field)
Использование
add_filter( 'post_comment_count', 'wp_kama_post_comment_count_filter', 10, 3 ); /** * Function for `post_comment_count` filter-hook. * * @param mixed $value Value of the unprefixed post field. * @param int $post_id Post ID * @param string $context Context for how to sanitize the field. Accepts 'raw', 'edit', 'db', 'display', 'attribute', or 'js'. * * @return mixed */ function wp_kama_post_comment_count_filter( $value, $post_id, $context ){ // filter... return $value; }
- $value(разное)
- Value of the unprefixed post field.
- $post_id(int)
- Post ID
- $context(строка)
- Context for how to sanitize the field. Accepts 'raw', 'edit', 'db', 'display', 'attribute', or 'js'.
По умолчанию: 'display'
Список изменений
С версии 2.3.0 | Введена. |
Где вызывается хук
post_comment_count
wp-includes/post.php 3164
$value = apply_filters( "post_{$field}", $value, $post_id, $context );