From 51559327b20c4e58df092623bfbd1a141b6558ed Mon Sep 17 00:00:00 2001 From: tellyworth Date: Wed, 8 Dec 2021 19:02:12 +1100 Subject: [PATCH 1/2] Allow the use of tag slugs in the wp:query block --- source/wp-content/themes/wporg-news-2021/functions.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/wp-content/themes/wporg-news-2021/functions.php b/source/wp-content/themes/wporg-news-2021/functions.php index a6ca2f88..9096ce9d 100644 --- a/source/wp-content/themes/wporg-news-2021/functions.php +++ b/source/wp-content/themes/wporg-news-2021/functions.php @@ -324,6 +324,13 @@ function custom_query_block_attributes( $parsed_block ) { $parsed_block[ 'attrs' ][ 'query' ][ 'categoryIds' ] = [ $category->term_id ]; } } + if ( isset( $parsed_block[ 'attrs' ][ 'query' ][ 'tag' ] ) ) { + $tag = get_term_by( 'slug', $parsed_block[ 'attrs' ][ 'query' ][ 'tag' ], 'post_tag' ); + if ( $tag ) { + $parsed_block[ 'attrs' ][ 'query' ][ 'tagIds' ] = [ $tag->term_id ]; + } + + } } return $parsed_block; From f01e4be7a8f30bfc612055d0f1818e1e57564a6f Mon Sep 17 00:00:00 2001 From: tellyworth Date: Wed, 8 Dec 2021 19:02:39 +1100 Subject: [PATCH 2/2] Use tag slug instead of id so it survives export --- .../block-template-parts/front-page/people-of-wordpress.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/wp-content/themes/wporg-news-2021/block-template-parts/front-page/people-of-wordpress.html b/source/wp-content/themes/wporg-news-2021/block-template-parts/front-page/people-of-wordpress.html index 46472e1e..3774b655 100644 --- a/source/wp-content/themes/wporg-news-2021/block-template-parts/front-page/people-of-wordpress.html +++ b/source/wp-content/themes/wporg-news-2021/block-template-parts/front-page/people-of-wordpress.html @@ -1,4 +1,4 @@ - +

People of WordPress