Repository navigation
Point ability descriptions at the Query Loop for related posts - #147
fabiankaegy wants to merge 2 commits into
Conversation
…ated posts The read-only abilities return related IDs, which agents tend to paste into a hand-picked list. The descriptions now say to use a Query Loop filtered by the relationship for display, and rel_name is described as the relationship query name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| array( | ||
| 'label' => __( 'Content Connect', 'wp-content-connect' ), | ||
| 'description' => __( 'Post-to-post and post-to-user relationships.', 'wp-content-connect' ), | ||
| 'description' => __( 'Post-to-post and post-to-user relationships. These abilities read relationship data. To display related posts on the site, use a Query Loop (core/query) block filtered by the relationship, which stays in sync when relationships change.', 'wp-content-connect' ), |
There was a problem hiding this comment.
The guidance reads as if it covers every relationship, but the Query Loop extension only builds related_to_post filters, and only lists relationships whose post_type includes the loop's post type. Post-to-user relationships get no UI.
"Stays in sync" also overpromises: the block stores a fixed related_to_post (the sourcePost or the post being edited). In a single template or a synced pattern, every post shows the same list. And loops with inherit: true never hit query_loop_block_query_vars, so the filter is ignored there.
| 'description' => __( 'Post-to-post and post-to-user relationships. These abilities read relationship data. To display related posts on the site, use a Query Loop (core/query) block filtered by the relationship, which stays in sync when relationships change.', 'wp-content-connect' ), | |
| 'description' => __( 'Post-to-post and post-to-user relationships. These abilities read relationship data. To display posts related to a specific post, use a Query Loop (core/query) block with the relationship filter set (showRelated, relationshipKey, sourcePost) and inherit set to false; the list updates when that post\'s relationships change. Query Loop filtering supports post-to-post relationships only.', 'wp-content-connect' ), |
| array( | ||
| 'label' => __( 'Get Post Relationships', 'wp-content-connect' ), | ||
| 'description' => __( 'Lists the relationships that apply to a post, optionally including the related posts and users for each one.', 'wp-content-connect' ), | ||
| 'description' => __( 'Lists the relationships that apply to a post, optionally including the related posts and users for each one. To display related posts on the site, use a Query Loop (core/query) block filtered by the relationship instead of copying the related IDs into content.', 'wp-content-connect' ), |
There was a problem hiding this comment.
The category description already carries the Query Loop guidance. Repeating it in three strings with different wording means three strings to translate and three places to fix next time. Suggest a short pointer here.
| 'description' => __( 'Lists the relationships that apply to a post, optionally including the related posts and users for each one. To display related posts on the site, use a Query Loop (core/query) block filtered by the relationship instead of copying the related IDs into content.', 'wp-content-connect' ), | |
| 'description' => __( 'Lists the relationships that apply to a post, optionally including the related posts and users for each one. Read-only; see the category description for displaying related posts.', 'wp-content-connect' ), |
| array( | ||
| 'label' => __( 'Get Related Items', 'wp-content-connect' ), | ||
| 'description' => __( 'Lists the published posts or the users related to a post through one relationship, with pagination and ordering.', 'wp-content-connect' ), | ||
| 'description' => __( 'Lists the published posts or the users related to a post through one relationship, with pagination and ordering. Use it to inspect a relationship, not to build content: to display related posts on the site, use a Query Loop (core/query) block filtered by the relationship. A Query Loop updates when relationships change; IDs copied into a hand-picked list do not.', 'wp-content-connect' ), |
There was a problem hiding this comment.
This ability returns posts or users, but the guidance only covers posts. For a post-to-user relationship, "not to build content" leaves the agent with no working option, since the Query Loop cannot list users. Scoping it to posts fixes that.
| 'description' => __( 'Lists the published posts or the users related to a post through one relationship, with pagination and ordering. Use it to inspect a relationship, not to build content: to display related posts on the site, use a Query Loop (core/query) block filtered by the relationship. A Query Loop updates when relationships change; IDs copied into a hand-picked list do not.', 'wp-content-connect' ), | |
| 'description' => __( 'Lists the published posts or the users related to a post through one relationship, with pagination and ordering. Use it to inspect a relationship. To display related posts on the site, prefer a Query Loop (core/query) block filtered by the relationship over copying these IDs into content, since a copied list goes stale when the relationship changes.', 'wp-content-connect' ), |
| 'rel_key' => array( 'type' => 'string' ), | ||
| 'rel_type' => array( 'type' => 'string' ), | ||
| 'rel_name' => array( 'type' => 'string' ), | ||
| 'rel_name' => array( |
There was a problem hiding this comment.
Two problems with the hint:
- A segment with only
namefailsRelationshipQuery::is_valid_segment(), which also requiresrelated_to_postorrelated_to_user. An agent building[{"name": rel_name}]gets no WHERE clause and the loop returns every post. rel_nameis only unique per post-type pair. The block editor selects byrelationshipKey, which matchesrel_key. An agent passingrel_namethere falls back torelationships[0].
| 'rel_name' => array( | |
| 'rel_name' => array( | |
| 'type' => 'string', | |
| 'description' => __( 'The relationship name. In a relationship query segment it is `name`, paired with `related_to_post` or `related_to_user`. Not unique across post types; use rel_key to identify a relationship.', 'wp-content-connect' ), | |
| ), |
The same entry is duplicated in get_relationship_definition_schema() and get_post_relationship_schema(). Suggestion: move into a shared helper, the way get_relationship_side_schema() handles the side fields.
Category description names the filter attributes, needs inherit false, and says Query Loop filtering is post-to-post only. Other ability descriptions point back to it. rel_name schema moves to a shared helper and says it pairs with related_to_post/related_to_user and is not unique across post types. CHANGELOG credits #147. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Category description names Query Loop filter attributes (showRelated, relationshipKey, sourcePost), needs inherit false, post-to-post only. get-post-relationships and get-related-items point to it. rel_name schema moves to shared helper: pairs with related_to_post or related_to_user, not unique across post types, use rel_key. Co-authored-by: Sérgio Santos <me@s3rgiosan.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This change is on 21626a2 applies the suggestions from my review. The changelog credits you for this change. GitHub did not let me merge this PR. A stacked PR merges only through the async merge API, and that operation also merges the downstack PRs. Here, it would also merge #142 into #148 now has conflicts with its base. It needs a rebase onto |
Description
Stacked on #142.
content-connect/get-related-itemsreturns related IDs. An agent asked to "add related articles" calls it, gets IDs, and pastes them into a post picker. That list goes stale as soon as the relationship changes, and nothing in the ability descriptions suggests a better route.The ability descriptions are the one thing every MCP client reads, so this PR changes them:
core/query) filtered by the relationship.get-related-itemssays it's for inspecting a relationship, not building content, and why a copied list goes stale.get-post-relationshipsgets the same pointer, sincecontext: embedalso returns related IDs.rel_namein both output schemas now says it's thenameused in a relationship query.Only descriptions change. #148 adds an ability that returns the Query Loop markup and updates these descriptions to name it.
How to test
GET /wp-json/wp-abilities/v1/abilities?category=content-connectshows the new descriptions.npm run test:phppasses.Changelog Entry
None. This refines the unreleased abilities from #142.