default_topic_count_scale()
云策文档标注
概述
default_topic_count_scale() 是 WordPress 中用于标签链接的默认主题计数缩放函数,它根据标签关联的帖子数量计算缩放后的计数,常用于标签云等显示场景。
关键要点
- 函数接受一个整数参数 $count,表示标签关联的帖子数量。
- 返回一个整数,表示缩放后的计数,计算公式为 (int) round( log10( $count + 1 ) * 100 )。
- 该函数自 WordPress 2.9.0 版本引入,用于优化标签计数的显示效果。
代码示例
function default_topic_count_scale( $count ) {
return (int) round( log10( $count + 1 ) * 100 );
}
原文内容
Default topic count scaling for tag links.
Parameters
$countintrequired-
Number of posts with that tag.
Source
function default_topic_count_scale( $count ) {
return (int) round( log10( $count + 1 ) * 100 );
}
Changelog
| Version | Description |
|---|---|
| 2.9.0 | Introduced. |