Add "Curated Posts" control to set the query "include" parameter#15
Add "Curated Posts" control to set the query "include" parameter#15goldenapples wants to merge 2 commits into
Conversation
Adds a new "Curated Posts" panel in the editor to search for, select, and reorder curated posts for a query loop. This overrides any other query filters or parameters set.
Playwright test resultsDetails
|
kadamwhite
left a comment
There was a problem hiding this comment.
This plugin's getting more and more complex. Love it, but took a bit to reason through! Think this is a ✅ from me overall, but I'm not certain about the "any" handling or the purported search fallback in getEntity Records.
| /** | ||
| * Resolve a list of post IDs to lightweight {id, title, type} records via the | ||
| * `core` data store. Scoped to the query's post type when known so we use the | ||
| * right REST entity; falls back to the search endpoint for mixed/unknown types. |
There was a problem hiding this comment.
I don't see this search fallback logic, is this comment outdated, or is that behavior triggered by passing any to getEntityRecords?
| }, [ records ] ); | ||
|
|
||
| const setInclude = ( nextIds ) => { | ||
| const { include: _omit, orderBy: _omitOrder, ...rest } = query || {}; |
There was a problem hiding this comment.
Why do we explicitly strip the orderBy here? I get that we overwrite it at the end to include, but I'm surprised we'd remove it from play first.
| // Resolve the post type's REST base so the search hits the right endpoint. | ||
| const restBase = useSelect( | ||
| ( select ) => { | ||
| const type = postType && postType !== 'any' ? postType : 'post'; |
There was a problem hiding this comment.
It looks like this sets post when you pass any, assume that's intentional? This wouldn't seem to actually handle "any," in the way I'd interpret it...?
Note to self, build_query_vars_from_query_block will fall back to post so this is consistent.
|
I've not tested/reviewed the code, but love it as this is such a common requirement. However we've been using it in conjunction with the Advanced Query Loop plugin, which supports this functionality. Could this conflict? |
|
This is duplicating #12 I think, and is encroaching on what the Advanced Query Loop plugin provides so not something I think needs to be part of this plugin. |
Adds a new "Curated Posts" panel in the editor to search for, select, and reorder curated posts for a query loop. This overrides any other query filters or parameters set.