update_postmeta_cache()
云策文档标注
概述
update_postmeta_cache() 函数用于更新一组文章 ID 的元数据缓存,通过执行 SQL 查询获取元数据并缓存,避免后续函数重复查询数据库。
关键要点
- 函数参数:$post_ids,必需,为文章 ID 数组。
- 返回值:成功时返回元数据数组,若无内容可更新则返回 false。
- 内部实现:调用 update_meta_cache('post', $post_ids) 来更新元数据缓存。
- 相关函数:update_meta_cache()、update_post_caches()、_prime_post_caches()。
- 引入版本:WordPress 2.1.0。
代码示例
function update_postmeta_cache( $post_ids ) {
return update_meta_cache( 'post', $post_ids );
}
原文内容
Updates metadata cache for a list of post IDs.
Description
Performs SQL query to retrieve the metadata for the post IDs and updates the metadata cache for the posts. Therefore, the functions, which call this function, do not need to perform SQL queries on their own.
Parameters
$post_idsint[]required-
Array of post IDs.
Source
function update_postmeta_cache( $post_ids ) {
return update_meta_cache( 'post', $post_ids );
}
Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |