
如何设置Nginx和Apach反向代理
render_block_core_query_title ( $attributes )
render_block_core_query_title: 这个函数用来渲染WordPress中的查询块的标题。它负责为该块的标题生成HTML标记,用户可以自定义。
在服务器上渲染`core/query-title’区块。
目前,它只支持Archive title,使用查询的对象信息。
function render_block_core_query_title( $attributes ) { $type = isset( $attributes['type'] ) ? $attributes['type'] : null; $is_archive = is_archive(); $is_search = is_search(); if ( ! $type || ( 'archive' === $type && ! $is_archive ) || ( 'search' === $type && ! $is_search ) ) { return ''; } $title = ''; if ( $is_archive ) { $show_prefix = isset( $attributes['showPrefix'] ) ? $attributes['showPrefix'] : true; if ( ! $show_prefix ) { $filter_title = function( $title, $original_title ) { return $original_title; }; add_filter( 'get_the_archive_title', $filter_title, 10, 2 ); $title = get_the_archive_title(); remove_filter( 'get_the_archive_title', $filter_title, 10, 2 ); } else { $title = get_the_archive_title(); } } if ( $is_search ) { $title = __( 'Search results' ); if ( isset( $attributes['showSearchTerm'] ) && $attributes['showSearchTerm'] ) { $title = sprintf( /* translators: %s is the search term. */ __( 'Search results for: "%s"' ), get_search_query() ); } } $tag_name = isset( $attributes['level'] ) ? 'h' . (int) $attributes['level'] : 'h1'; $align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); return sprintf( '<%1$s %2$s>%3$s</%1$s>', $tag_name, $wrapper_attributes, $title ); }