diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index 9ee8e557f6..1017e41417 100644 --- a/src/wp-admin/includes/template.php +++ b/src/wp-admin/includes/template.php @@ -2200,6 +2200,8 @@ function get_post_states( $post ) { * @return string Media states string. */ function _media_states( $post ) { + static $header_images; + $media_states = array(); $stylesheet = get_option( 'stylesheet' ); @@ -2207,7 +2209,9 @@ function _media_states( $post ) { $meta_header = get_post_meta( $post->ID, '_wp_attachment_is_custom_header', true ); if ( is_random_header_image() ) { - $header_images = wp_list_pluck( get_uploaded_header_images(), 'attachment_id' ); + if ( ! isset( $header_images ) ) { + $header_images = wp_list_pluck( get_uploaded_header_images(), 'attachment_id' ); + } if ( $meta_header === $stylesheet && in_array( $post->ID, $header_images, true ) ) { $media_states[] = __( 'Header Image' );