Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Block theme support for Create page.
The technique previously introduced to support the Docs directory in block themes worked because the `bp_doc` archive query successfully matched at least one item. It's important that the query match at least one item, otherwise the search for the `post-excerpt` string will never succeed, since the query block will render to show a `query-no-results` element instead. This limitation in the technique meant that the Create page would not work in block themes, since the `post_type=bp_doc&create=1` query would never match any items. BuddyPress's theme compatibility layer intends to work around the 404/no-results issue by using `bp_theme_compat_reset_post()`. This function resets WP's global query with a "dummy" post object, which in traditional themes tricks the theme into thinking that the query matches a result. The technique doesn't work properly in block themes, because of load order: In a block theme using the `core/query` block and the 'inherit' attribute, the query is accessed at the `template_include` hook. This causes race conditions with BP's "dependency" system that loads theme compatibility at 'bp_template_include'. The workaround is to run the theme-compatibility reset immediately before running the template content through `render_block()` in the Docs theme compatibility layer. This ensures that the dummy post is set at the time that WP renders the `core/query` block, avoiding "no results". See #728.
- Loading branch information