wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
update_post_caches › WordPress Function
Seit1.5.0
Veraltetn/v
› update_post_caches ( $posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true )
Parameter: (4) |
|
Definiert in: |
|
Codex: |
Updates post, term, and metadata caches for a list of post objects.
Ähnliche Funktionen: update_post_cache, update_postmeta_cache, update_site_cache, update_post_parent_caches, update_post_author_caches
Quellcode
function update_post_caches( &$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true ) { // No point in doing all this work if we didn't match any posts. if ( ! $posts ) { return; } update_post_cache( $posts ); $post_ids = array(); foreach ( $posts as $post ) { $post_ids[] = $post->ID; } if ( ! $post_type ) { $post_type = 'any'; } if ( $update_term_cache ) { if ( is_array( $post_type ) ) { $ptypes = $post_type; } elseif ( 'any' === $post_type ) { $ptypes = array(); // Just use the post_types in the supplied posts. foreach ( $posts as $post ) { $ptypes[] = $post->post_type; } $ptypes = array_unique( $ptypes ); } else { $ptypes = array( $post_type ); } if ( ! empty( $ptypes ) ) { update_object_term_cache( $post_ids, $ptypes ); } } if ( $update_meta_cache ) { update_postmeta_cache( $post_ids ); } }