Make WordPress Core

Changeset 54767


Ignore:
Timestamp:
11/08/2022 06:30:53 PM (2 years ago)
Author:
desrosj
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.
Merges [54751] to the 6.1 branch.
Fixes #56902.

Location:
branches/6.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.1

  • branches/6.1/src/wp-includes/block-template-utils.php

    r54753 r54767  
    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.