On this page
update_post_parent_caches( WP_Post[] $posts )
Updates parent post caches for a list of post objects.
Parameters
$postsWP_Post[] Required-
Array of post objects.
Source
File: wp-includes/post.php. View all references
function update_post_parent_caches( $posts ) {
$parent_ids = wp_list_pluck( $posts, 'post_parent' );
$parent_ids = array_map( 'absint', $parent_ids );
$parent_ids = array_unique( array_filter( $parent_ids ) );
if ( ! empty( $parent_ids ) ) {
_prime_post_caches( $parent_ids, false );
}
}
Related
Uses
| Uses | Description |
|---|---|
| wp_list_pluck() wp-includes/functions.php | Plucks a certain field out of each object or array in an array. |
| _prime_post_caches() wp-includes/post.php | Adds any posts from the given IDs to the cache that do not already exist in cache. |
Used By
| Used By | Description |
|---|---|
| WP_REST_Posts_Controller::get_items() wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php | Retrieves a collection of posts. |
| wp_ajax_query_attachments() wp-admin/includes/ajax-actions.php | Ajax handler for querying attachments. |
| WP_Media_List_Table::prepare_items() wp-admin/includes/class-wp-media-list-table.php |
Changelog
| Version | Description |
|---|---|
| 6.1.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/update_post_parent_caches