编辑:term-template.php
<?php /** * Server-side rendering of the `core/term-template` block. * * @package WordPress */ /** * Renders the `core/term-template` block on the server. * * @since 6.9.0 * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. * * @return string Returns the output of the term template. */ function render_block_core_term_template( $attributes, $content, $block ) { if ( ! isset( $block->context ) || empty( $block->context['termQuery'] ) ) { return ''; } $query = $block->context['termQuery']; $query_args = array( 'number' => $query['perPage'], 'order' => $query['order'], 'orderby' => $query['orderBy'], 'hide_empty' => $query['hideEmpty'], ); $inherit_query = isset( $query['inherit'] ) && $query['inherit'] && ( is_tax() || is_category() || is_tag() ); if ( $inherit_query ) { // Get the current term and taxonomy from the queried object. $queried_object = get_queried_object(); // For hierarchical taxonomies, show children of the current term. // For non-hierarchical taxonomies, show all terms (don't set parent). if ( is_taxonomy_hierarchical( $queried_object->taxonomy ) ) { // If showNested is true, use child_of to include nested terms. // Otherwise, use parent to show only direct children. if ( ! empty( $query['showNested'] ) ) { $query_args['child_of'] = $queried_object->term_id; } else { $query_args['parent'] = $queried_object->term_id; } } $query_args['taxonomy'] = $queried_object->taxonomy; } else { // If not inheriting set `taxonomy` from the block attribute. $query_args['taxonomy'] = $query['taxonomy']; // If we are including specific terms we ignore `showNested` argument. if ( ! empty( $query['include'] ) ) { $query_args['include'] = array_unique( array_map( 'intval', $query['include'] ) ); $query_args['orderby'] = 'include'; $query_args['order'] = 'asc'; } elseif ( is_taxonomy_hierarchical( $query['taxonomy'] ) && empty( $query['showNested'] ) ) { // We set parent only when inheriting from the taxonomy archive context or not // showing nested terms, otherwise nested terms are not displayed. $query_args['parent'] = 0; } } $terms_query = new WP_Term_Query( $query_args ); $terms = $terms_query->get_terms(); if ( ! $terms || is_wp_error( $terms ) ) { return ''; } $content = ''; foreach ( $terms as $term ) { // Get an instance of the current Term Template block. $block_instance = $block->parsed_block; // Set the block name to one that does not correspond to an existing registered block. // This ensures that for the inner instances of the Term Template block, we do not render any block supports. $block_instance['blockName'] = 'core/null'; $term_id = $term->term_id; $taxonomy = $term->taxonomy; $filter_block_context = static function ( $context ) use ( $term_id, $taxonomy ) { $context['termId'] = $term_id; $context['taxonomy'] = $taxonomy; return $context; }; // Use an early priority to so that other 'render_block_context' filters have access to the values. add_filter( 'render_block_context', $filter_block_context, 1 ); // Render the inner blocks of the Term Template block with `dynamic` set to `false` to prevent calling // `render_callback` and ensure that no wrapper markup is included. $block_content = ( new WP_Block( $block_instance ) )->render( array( 'dynamic' => false ) ); remove_filter( 'render_block_context', $filter_block_context, 1 ); // Wrap the render inner blocks in a `li` element with the appropriate term classes. $term_classes = "wp-block-term term-{$term->term_id} {$term->taxonomy} taxonomy-{$term->taxonomy}"; $content .= '<li class="' . esc_attr( $term_classes ) . '">' . $block_content . '</li>'; } $classnames = ''; if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { $classnames .= 'has-link-color'; } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => trim( $classnames ) ) ); return sprintf( '<ul %s>%s</ul>', $wrapper_attributes, $content ); } /** * Registers the `core/term-template` block on the server. * * @since 6.9.0 */ function register_block_core_term_template() { register_block_type_from_metadata( __DIR__ . '/term-template', array( 'render_callback' => 'render_block_core_term_template', ) ); } add_action( 'init', 'register_block_core_term_template' );
保存文件
位置:
home
/
robertofarias
/
public_html
/
wp-includes
/
blocks
批量上传
创建
创建
批量权限
批量删除
名称
权限
大小
修改时间
操作
↑ 返回上级
-
-
-
-
accordion
drwxr-xr-x
-
2026-05-01 02:14
权限
删除
重命名
accordion-heading
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
accordion-item
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
accordion-panel
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
archives
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
audio
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
avatar
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
block
drwxr-xr-x
-
2024-07-17 11:52
权限
删除
重命名
button
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
buttons
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
calendar
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
categories
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
code
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
column
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
columns
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comment-author-name
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
comment-content
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comment-date
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
comment-edit-link
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
comment-reply-link
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
comment-template
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments-pagination
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments-pagination-next
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments-pagination-numbers
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments-pagination-previous
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
comments-title
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
cover
drwxr-xr-x
-
2026-05-01 02:14
权限
删除
重命名
details
drwxr-xr-x
-
2026-05-01 03:37
权限
删除
重命名
embed
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
file
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
footnotes
drwxr-xr-x
-
2023-08-09 11:43
权限
删除
重命名
freeform
drwxr-xr-x
-
2026-05-01 03:14
权限
删除
重命名
gallery
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
group
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
heading
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
home-link
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
html
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
image
drwxr-xr-x
-
2023-11-08 10:55
权限
删除
重命名
latest-comments
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
latest-posts
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
legacy-widget
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
list
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
list-item
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
loginout
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
math
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
media-text
drwxr-xr-x
-
2026-05-01 01:56
权限
删除
重命名
missing
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
more
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
navigation
drwxr-xr-x
-
2023-11-08 10:55
权限
删除
重命名
navigation-link
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
navigation-submenu
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
nextpage
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
page-list
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
page-list-item
drwxr-xr-x
-
2023-03-30 09:26
权限
删除
重命名
paragraph
drwxr-xr-x
-
2026-05-01 03:14
权限
删除
重命名
pattern
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-author
drwxr-xr-x
-
2025-12-04 05:42
权限
删除
重命名
post-author-biography
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
post-author-name
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
post-comments-count
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
post-comments-form
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-comments-link
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
post-content
drwxr-xr-x
-
2025-04-16 11:06
权限
删除
重命名
post-date
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-excerpt
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-featured-image
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-navigation-link
drwxr-xr-x
-
2023-03-30 09:26
权限
删除
重命名
post-template
drwxr-xr-x
-
2025-04-16 11:06
权限
删除
重命名
post-terms
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
post-time-to-read
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
post-title
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
preformatted
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
pullquote
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query
drwxr-xr-x
-
2024-04-03 10:16
权限
删除
重命名
query-no-results
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-pagination
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-pagination-next
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-pagination-numbers
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-pagination-previous
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-title
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
query-total
drwxr-xr-x
-
2025-04-16 11:06
权限
删除
重命名
quote
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
read-more
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
rss
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
search
drwxr-xr-x
-
2026-05-01 03:14
权限
删除
重命名
separator
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
shortcode
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
site-logo
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
site-tagline
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
site-title
drwxr-xr-x
-
2023-03-30 09:26
权限
删除
重命名
social-link
drwxr-xr-x
-
2026-05-01 02:12
权限
删除
重命名
social-links
drwxr-xr-x
-
2026-05-01 02:25
权限
删除
重命名
spacer
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
table
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
tag-cloud
drwxr-xr-x
-
2024-11-13 13:00
权限
删除
重命名
template-part
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
term-count
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
term-description
drwxr-xr-x
-
2023-08-09 11:43
权限
删除
重命名
term-name
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
term-template
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
terms-query
drwxr-xr-x
-
2025-12-04 05:41
权限
删除
重命名
text-columns
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
verse
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
video
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
widget-group
drwxr-xr-x
-
2022-11-15 19:03
权限
删除
重命名
accordion-item.php
-rw-r--r--
2.35 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
accordion.php
-rw-r--r--
1.12 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
archives.php
-rw-r--r--
4.31 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
blocks-json.php
-rw-r--r--
213.43 KB
2026-02-27 10:54
编辑
下载
权限
删除
重命名
calendar.php
-rw-r--r--
5.93 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
categories.php
-rw-r--r--
4.54 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
comments-pagination-next.php
-rw-r--r--
1.88 KB
2024-11-13 13:00
编辑
下载
权限
删除
重命名
comments-pagination-numbers.php
-rw-r--r--
1.59 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
comments-pagination.php
-rw-r--r--
1.23 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
comments-title.php
-rw-r--r--
2.71 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
cover.php
-rw-r--r--
3.1 KB
2025-04-16 11:06
编辑
下载
权限
删除
重命名
error_log
-rw-r--r--
39.29 KB
2026-05-01 18:01
编辑
下载
权限
删除
重命名
footnotes.php
-rw-r--r--
3.68 KB
2024-04-03 10:16
编辑
下载
权限
删除
重命名
gallery.php
-rw-r--r--
6.29 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
heading.php
-rw-r--r--
1.27 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
latest-comments.php
-rw-r--r--
4.91 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
legacy-widget.php
-rw-r--r--
3.92 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
loginout.php
-rw-r--r--
1.63 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
media-text.php
-rw-r--r--
4.28 KB
2024-11-13 13:00
编辑
下载
权限
删除
重命名
page-list-item.php
-rw-r--r--
361 B
2024-07-17 11:51
编辑
下载
权限
删除
重命名
page-list.php
-rw-r--r--
13.29 KB
2024-11-13 13:00
编辑
下载
权限
删除
重命名
post-author-biography.php
-rw-r--r--
1.49 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
post-author-name.php
-rw-r--r--
1.91 KB
2025-05-01 11:02
编辑
下载
权限
删除
重命名
post-author.php
-rw-r--r--
2.67 KB
2025-05-01 11:02
编辑
下载
权限
删除
重命名
post-excerpt.php
-rw-r--r--
3.53 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
post-featured-image.php
-rw-r--r--
9.14 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
post-time-to-read.php
-rw-r--r--
6.34 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
query-no-results.php
-rw-r--r--
1.8 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
query-pagination-next.php
-rw-r--r--
3.69 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
query-pagination-numbers.php
-rw-r--r--
4.66 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
query-pagination.php
-rw-r--r--
1.15 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
query-title.php
-rw-r--r--
2.87 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
query-total.php
-rw-r--r--
2.48 KB
2025-04-16 11:06
编辑
下载
权限
删除
重命名
search.php
-rw-r--r--
23.26 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
site-tagline.php
-rw-r--r--
1.17 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名
site-title.php
-rw-r--r--
1.82 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
social-link.php
-rw-r--r--
66.15 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
tag-cloud.php
-rw-r--r--
1.55 KB
2024-11-13 13:00
编辑
下载
权限
删除
重命名
term-count.php
-rw-r--r--
1.8 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
term-description.php
-rw-r--r--
1.73 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
term-name.php
-rw-r--r--
2.02 KB
2025-12-04 05:41
编辑
下载
权限
删除
重命名
term-template.php
-rw-r--r--
4.41 KB
2026-02-27 10:54
编辑
下载
权限
删除
重命名
widget-group.php
-rw-r--r--
2.38 KB
2024-07-17 11:51
编辑
下载
权限
删除
重命名