函数文档

update_page_cache()

💡 云策文档标注

概述

update_page_cache() 是 update_post_cache() 的别名函数,用于在缓存中更新页面对象。自 WordPress 3.4.0 版本起已被弃用,建议开发者直接使用 update_post_cache()。

关键要点

  • update_page_cache() 是 update_post_cache() 的别名,两者功能相同,因为 WordPress 中页面(pages)被视为一种特殊的文章(posts)。
  • 该函数自 3.4.0 版本起被标记为弃用,使用时会触发 _deprecated_function() 警告。
  • 函数参数为页面对象数组,通过引用传递,用于更新缓存中的页面数据。
  • 相关函数包括 update_post_cache() 和 _deprecated_function(),开发者应迁移代码以避免使用弃用函数。

代码示例

function update_page_cache( &$pages ) {
    _deprecated_function( __FUNCTION__, '3.4.0', 'update_post_cache()' );
    update_post_cache( $pages );
}

注意事项

在开发新代码或维护旧代码时,应避免使用 update_page_cache(),转而使用 update_post_cache() 以确保兼容性和最佳实践。


📄 原文内容

Alias of update_post_cache() .

Description

See also

Parameters

$pagesarrayrequired
list of page objects

Source

function update_page_cache( &$pages ) {
	_deprecated_function( __FUNCTION__, '3.4.0', 'update_post_cache()' );

	update_post_cache( $pages );
}

Changelog

Version Description
3.4.0 Deprecated. Use update_post_cache()
1.5.1 Introduced.