Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use positive conditionals
  • Loading branch information
t-hamano committed Feb 19, 2024
commit cc54872daa2da265f64bd907ff321d1aa82247ea
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
* @return string Returns the rendered post author biography block.
*/
function render_block_core_post_author_biography( $attributes, $content, $block ) {
$author_id = isset( $block->context['postId'] ) ? get_post_field( 'post_author', $block->context['postId'] ) : get_query_var( 'author' );
if ( isset( $block->context['postId'] ) ) {
$author_id = get_post_field( 'post_author', $block->context['postId'] );
} else {
$author_id = get_query_var( 'author' );
}

if ( empty( $author_id ) ) {
return '';
Expand Down
6 changes: 5 additions & 1 deletion packages/block-library/src/post-author-name/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
* @return string Returns the rendered post author name block.
*/
function render_block_core_post_author_name( $attributes, $content, $block ) {
$author_id = isset( $block->context['postId'] ) ? get_post_field( 'post_author', $block->context['postId'] ) : get_query_var( 'author' );
if ( ! isset( $block->context['postId'] ) ) {
$author_id = get_post_field( 'post_author', $block->context['postId'] );
} else {
$author_id = get_query_var( 'author' );
}

if ( empty( $author_id ) ) {
return '';
Expand Down