Make WordPress Core


Ignore:
Timestamp:
06/30/2022 03:46:06 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Editor: Ensure only the main query is modified when resolving template for new posts.

This adds a check for the main query in _resolve_template_for_new_post() to fix a 404 response when resolving template for new posts or pages caused by the wrong query being modified.

Original PR from Gutenberg repository:

Follow-up to [52316].

Props petitphp, zieladam, poena, ndiego, gziolo, kebbet, Mamaduka, manfcarlo.
See #56058.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-template.php

    r53093 r53593  
    313313 */
    314314function _resolve_template_for_new_post( $wp_query ) {
     315    if ( ! $wp_query->is_main_query() ) {
     316        return;
     317    }
     318
    315319    remove_filter( 'pre_get_posts', '_resolve_template_for_new_post' );
    316320
Note: See TracChangeset for help on using the changeset viewer.