Make WordPress Core

Changeset 54751 for trunk


Ignore:
Timestamp:
11/04/2022 06:22:17 PM (4 years ago)
Author:
jorgefilipecosta
Message:

Fix: Category specific templates always appear as not found.

According to the docs in developer.wordpress.org/reference/classes/wp_term_query/query WP_Term_Query:->query( string|array $query ) returns WP_Term[]|int[]|string[]|string, and we were using an inexistent object property terms making it always empty and look like the taxonomy did not exist.

Props mamaduka, mikachan, ockham, franz00.
See #56902.

File:
1 edited

Legend:

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

    r54494 r54751  
    638638        $terms_query = $term_query->query( $args );
    639639
    640         if ( empty( $terms_query->terms ) ) {
     640        if ( empty( $terms_query ) ) {
    641641                $template->title = sprintf(
    642642                        /* translators: Custom template title in the Site Editor, referencing a taxonomy term that was not found. 1: Taxonomy singular name, 2: Term slug. */
     
    648648        }
    649649
    650         $term_title = $terms_query->terms[0]->name;
     650        $term_title = $terms_query[0]->name;
    651651
    652652        $template->title = sprintf(
     
    672672        $terms_with_same_title_query = $term_query->query( $args );
    673673
    674         if ( count( $terms_with_same_title_query->terms ) > 1 ) {
     674        if ( count( $terms_with_same_title_query ) > 1 ) {
    675675                $template->title = sprintf(
    676676                        /* translators: Custom template title in the Site Editor. 1: Template title, 2: Term slug. */
Note: See TracChangeset for help on using the changeset viewer.