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.
Built from https://develop.svn.wordpress.org/trunk@54751


git-svn-id: http://core.svn.wordpress.org/trunk@54303 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
jorgefilipecosta 2022-11-04 18:24:12 +00:00
parent 508485887f
commit 379096eca1
2 changed files with 4 additions and 4 deletions

View File

@ -637,7 +637,7 @@ function _wp_build_title_and_description_for_taxonomy_block_template( $taxonomy,
$args = wp_parse_args( $args, $default_args );
$terms_query = $term_query->query( $args );
if ( empty( $terms_query->terms ) ) {
if ( empty( $terms_query ) ) {
$template->title = sprintf(
/* translators: Custom template title in the Site Editor, referencing a taxonomy term that was not found. 1: Taxonomy singular name, 2: Term slug. */
__( 'Not found: %1$s (%2$s)' ),
@ -647,7 +647,7 @@ function _wp_build_title_and_description_for_taxonomy_block_template( $taxonomy,
return false;
}
$term_title = $terms_query->terms[0]->name;
$term_title = $terms_query[0]->name;
$template->title = sprintf(
/* translators: Custom template title in the Site Editor. 1: Taxonomy singular name, 2: Term title. */
@ -671,7 +671,7 @@ function _wp_build_title_and_description_for_taxonomy_block_template( $taxonomy,
$args = wp_parse_args( $args, $default_args );
$terms_with_same_title_query = $term_query->query( $args );
if ( count( $terms_with_same_title_query->terms ) > 1 ) {
if ( count( $terms_with_same_title_query ) > 1 ) {
$template->title = sprintf(
/* translators: Custom template title in the Site Editor. 1: Template title, 2: Term slug. */
__( '%1$s (%2$s)' ),

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.2-alpha-54750';
$wp_version = '6.2-alpha-54751';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.