Changeset 53929 for trunk/src/wp-includes/blocks/query-no-results.php
- Timestamp:
- 08/23/2022 03:40:25 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/query-no-results.php
r53157 r53929 20 20 } 21 21 22 $page_key 23 $page 24 $query_args = build_query_vars_from_query_block( $block, $page ); 22 $page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page'; 23 $page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ]; 24 25 25 // Override the custom query with the global query if needed. 26 26 $use_global_query = ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ); 27 27 if ( $use_global_query ) { 28 28 global $wp_query; 29 if ( $wp_query && isset( $wp_query->query_vars ) && is_array( $wp_query->query_vars ) ) { 30 $query_args = wp_parse_args( $wp_query->query_vars, $query_args ); 31 } 29 $query = $wp_query; 30 } else { 31 $query_args = build_query_vars_from_query_block( $block, $page ); 32 $query = new WP_Query( $query_args ); 32 33 } 33 $query = new WP_Query( $query_args );34 34 35 35 if ( $query->have_posts() ) { … … 37 37 } 38 38 39 wp_reset_postdata(); 39 if ( ! $use_global_query ) { 40 wp_reset_postdata(); 41 } 40 42 41 43 return sprintf(
Note: See TracChangeset
for help on using the changeset viewer.