From 439e1f44cca14d41ce78b3717aad9799a08a74d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Ka=CC=88gy?= Date: Wed, 14 Oct 2026 08:22:31 +0200 Subject: [PATCH 1/2] feat: point ability descriptions at the query loop for displaying related 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 --- includes/Abilities.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/includes/Abilities.php b/includes/Abilities.php index c3d491f..8631fa9 100644 --- a/includes/Abilities.php +++ b/includes/Abilities.php @@ -58,7 +58,7 @@ public function register_category() { self::CATEGORY, 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' ), ) ); } @@ -101,7 +101,7 @@ public function register_abilities() { 'content-connect/get-post-relationships', 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' ), 'category' => self::CATEGORY, 'input_schema' => self::get_input_schema( self::get_post_input_args( ( new PostRelationshipsRoute() )->get_collection_params() ) ), 'output_schema' => array( @@ -124,7 +124,7 @@ public function register_abilities() { 'content-connect/get-related-items', 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' ), 'category' => self::CATEGORY, 'input_schema' => self::get_input_schema( self::get_post_input_args( $related_args ) ), 'output_schema' => array( @@ -411,7 +411,10 @@ private static function get_relationship_definition_schema() { 'properties' => array( 'rel_key' => array( 'type' => 'string' ), 'rel_type' => array( 'type' => 'string' ), - 'rel_name' => array( 'type' => 'string' ), + 'rel_name' => array( + 'type' => 'string', + 'description' => __( 'The relationship name, used as `name` in a relationship query.', 'wp-content-connect' ), + ), 'object_type' => array( 'type' => 'string' ), 'labels' => $side['labels'], 'sortable' => $side['sortable'], @@ -455,7 +458,10 @@ private static function get_post_relationship_schema() { array( 'rel_key' => array( 'type' => 'string' ), 'rel_type' => array( 'type' => 'string' ), - 'rel_name' => array( 'type' => 'string' ), + 'rel_name' => array( + 'type' => 'string', + 'description' => __( 'The relationship name, used as `name` in a relationship query.', 'wp-content-connect' ), + ), 'object_type' => array( 'type' => 'string' ), 'post_type' => array( 'type' => 'array', From 21626a2886d3d394b86745c08f83d5abc02daf34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Santos?= Date: Thu, 3 Dec 2026 12:57:22 +0000 Subject: [PATCH 2/2] fix: scope ability Query Loop guidance to what the block supports 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 --- CHANGELOG.md | 1 + includes/Abilities.php | 30 +++++++++++++++++++----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91b8edd..6f79692 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file, per [the Ke ### Added - Read-only Abilities API abilities `content-connect/get-relationships`, `content-connect/get-post-relationships`, and `content-connect/get-related-items`, exposed over REST and MCP, registered on WordPress 6.9+ only (props [@s3rgiosan](https://github.com/s3rgiosan)). +- Ability descriptions that point agents to a Query Loop (`core/query`) block filtered by the relationship for displaying related posts (props [@fabiankaegy](https://github.com/fabiankaegy) via [#147](https://github.com/10up/wp-content-connect/pull/147)). ## [2.0.0] - TBD diff --git a/includes/Abilities.php b/includes/Abilities.php index 8631fa9..7aef266 100644 --- a/includes/Abilities.php +++ b/includes/Abilities.php @@ -58,7 +58,7 @@ public function register_category() { self::CATEGORY, array( 'label' => __( 'Content Connect', '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' ), + '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' ), ) ); } @@ -101,7 +101,7 @@ public function register_abilities() { 'content-connect/get-post-relationships', 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. 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' ), 'category' => self::CATEGORY, 'input_schema' => self::get_input_schema( self::get_post_input_args( ( new PostRelationshipsRoute() )->get_collection_params() ) ), 'output_schema' => array( @@ -124,7 +124,7 @@ public function register_abilities() { 'content-connect/get-related-items', 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. 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' ), 'category' => self::CATEGORY, 'input_schema' => self::get_input_schema( self::get_post_input_args( $related_args ) ), 'output_schema' => array( @@ -395,6 +395,20 @@ private static function get_relationship_side_schema() { ); } + /** + * Builds the output schema for the relationship name. + * + * @since 2.1.0 + * + * @return array + */ + private static function get_rel_name_schema() { + return 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' ), + ); + } + /** * Builds the output schema for a registered relationship definition. * @@ -411,10 +425,7 @@ private static function get_relationship_definition_schema() { 'properties' => array( 'rel_key' => array( 'type' => 'string' ), 'rel_type' => array( 'type' => 'string' ), - 'rel_name' => array( - 'type' => 'string', - 'description' => __( 'The relationship name, used as `name` in a relationship query.', 'wp-content-connect' ), - ), + 'rel_name' => self::get_rel_name_schema(), 'object_type' => array( 'type' => 'string' ), 'labels' => $side['labels'], 'sortable' => $side['sortable'], @@ -458,10 +469,7 @@ private static function get_post_relationship_schema() { array( 'rel_key' => array( 'type' => 'string' ), 'rel_type' => array( 'type' => 'string' ), - 'rel_name' => array( - 'type' => 'string', - 'description' => __( 'The relationship name, used as `name` in a relationship query.', 'wp-content-connect' ), - ), + 'rel_name' => self::get_rel_name_schema(), 'object_type' => array( 'type' => 'string' ), 'post_type' => array( 'type' => 'array',