Skip to content

Server side rendering: ensure post types match #11

@bobbingwide

Description

@bobbingwide

While creating a generic template such as an Archive template I added the Field block for two different post types: Event and TODO.
When viewing the Events archive the server attempted to render both fields, even though the TODO field, was not valid for Events.

Image

There was also an issue where I'd changed the field name from _date to _start_date.
This was incorrectly echoing a value to the browser.

Requirements

  • Server side rendering shouldn't attempt to render a field which is not valid for the current content.
  • This should include invalid post types and/or field names.

Proposed solution

  • Check the post type of the current post against the selected post type for the Field.
  • Check the selected post type is a known post type.
  • Check the field is associated to the current post type.
  • For the front end, only display the output if all tests pass
  • For the editor, display something useful.
  • The logic should be consistent regardless of the value of the Show label toggle.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions