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

Post Content: Add some text to the Post Content block when used in a 404 context #33570

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
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
3 changes: 3 additions & 0 deletions packages/block-library/src/post-content/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ function render_block_core_post_content( $attributes, $content, $block ) {
static $seen_ids = array();

if ( ! isset( $block->context['postId'] ) ) {
if ( is_404() ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 - I don't think we should be adding hardcoded content like that. Such content should be editable and removable. Even if we added a wrapper with a css class here, someone would have to use css to hide it.

In my head this is something to be handled in 404 template but it seems I can't understand how this is not working. For example right now that we have a 404 template in tt1-blocks with a custom header block - we can't make this translatable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have any way to translate content in the HTML files for block templates, or block template parts. I've made some other suggestions for how we might work around the problem:
#33192
#33217

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless of the outcome of those PRs (I'm betting on #33217), this feels best absorbed by patterns than by hard-coded server-side logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if the patterns PR merges, I think this is a very useful tool. If I want to create a simple site with only one template, this allows me to do that...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I want to create a simple site with only one template

I think this is a good aspiration for FSE. Building simple sites should feel as convenient as working with a single template. But I think the current proposal is overloading base FSE blocks with meaning and hardcoded decisions.

return __( 'It looks like nothing was found at this location.' );
}
return '';
}

Expand Down