Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Author Name / Author Bio / Avatar: Not displayed in author archive template #55410

Closed
t-hamano opened this issue Oct 17, 2023 · 0 comments · Fixed by #55451
Closed

Author Name / Author Bio / Avatar: Not displayed in author archive template #55410

t-hamano opened this issue Oct 17, 2023 · 0 comments · Fixed by #55451
Assignees
Labels
[Block] Post Author Affects the Post Author Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@t-hamano
Copy link
Contributor

t-hamano commented Oct 17, 2023

Description

@them-es reported this problem in this comment.

When the following three blocks are inserted into the author archive template, the information is not displayed correctly on the front end.

  • Avatar
  • Author Name
  • Author Biography

On the other hand, the Post Author block displays the correct information. This is probably because it uses the author query parameter when no post context exists.

I think similar fallbacks are needed for these three blocks as well:

if ( ! isset( $block->context['postId'] ) ) {
$author_id = get_query_var( 'author' );
} else {
$author_id = get_post_field( 'post_author', $block->context['postId'] );
}

Step-by-step reproduction instructions

  • Add Author Archive template.
  • Enter the following code in the template's code editor and save it.
    <!-- wp:post-author {"showBio":true} /-->
    <!-- wp:post-author-name /-->
    <!-- wp:post-author-biography /-->
    <!-- wp:avatar /-->
    
  • Create a user with the bio. Please note your user ID.
  • Access http://localhost:8888/?author={user_id}.
  • The three blocks listed above should not display author information.
  • At the same time, you should see the following error:
    Warning: Undefined array key "postId" in /var/www/html/wp-content/plugins/gutenberg/build/block-library/blocks/avatar.php on line 34
    

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress 6.4-RC1
  • I also reproduce it with the latest Gutenberg trunk.

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Block] Post Author Affects the Post Author Block labels Oct 17, 2023
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Author Affects the Post Author Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant