wp_count_attachments
云策文档标注
概述
wp_count_attachments 是一个 WordPress 过滤器,用于按 MIME 类型过滤附件计数。它允许开发者修改基于 MIME 模式返回的附件数量对象。
关键要点
- 这是一个过滤器,用于调整附件计数,基于 MIME 类型进行过滤。
- 参数包括 $counts(包含按 MIME 类型计数的对象)和 $mime_type(MIME 模式字符串或数组)。
- 在 wp_count_attachments() 函数中使用,位于 wp-includes/post.php 文件中。
- 自 WordPress 3.7.0 版本引入。
代码示例
apply_filters( 'wp_count_attachments', (object) $counts, $mime_type );
原文内容
Filters the attachment counts by mime type.
Parameters
$countsstdClass-
An object containing the attachment counts by mime type.
$mime_typestring|string[]-
Array or comma-separated list of MIME patterns.
Source
return apply_filters( 'wp_count_attachments', (object) $counts, $mime_type );
Changelog
| Version | Description |
|---|---|
| 3.7.0 | Introduced. |