Make WordPress Core

Opened 111 minutes ago

Last modified 110 minutes ago

#66268 new feature request

Add `core/content-query` ability

Reported by: jorgefilipecosta Owned by:
Priority: normal Milestone: 7.2
Component: Abilities API Version:
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses:

Description

Introduces a new Abilities API ability, core/content-query, to retrieve and query post (including custom post types with ability support).

Core currently has core/get-user-info for the current authenticated user only. Agent/workflows use cases need to be able to look up any user when permissions allow it.

It should introduce a show_in_abilities option on register_post_type() to control which post types expose abilities, enabled by default at least for post and page initially.
It should support single-post retrieval by ID and multi-post querying with filters for status, author, etc...

Change History (1)

This ticket was mentioned in ​PR #12195 on ​WordPress/wordpress-develop by ​@jorgefilipecosta.


110 minutes ago
#1

  • Keywords has-unit-tests added

Part of ​https://github.com/WordPress/ai/issues/40. Ports the core/content-query ability from the AI plugin, added in ​https://github.com/WordPress/ai/pull/739, renamed from core/read-content in ​https://github.com/WordPress/ai/pull/1002, and updated with the read changes from ​https://github.com/WordPress/ai/pull/1025.

  • Adds the read-only core/content-query ability, in a new content category, through the internal WP_Content_Abilities class.
  • Adds a show_in_abilities post type argument that controls which post types the ability can read. It defaults to false; post and page set it to true.
  • The ability returns one post by id, or by post_type and slug, or a page of posts of one type filtered by status, author_slug, parent, or include, with fields to choose what each post returns.
  • Permissions follow the REST posts controller: raw fields need edit access, rendered fields need read access, and statuses other than publish need edit access, or read_private_posts for private.

Testing Instructions

Verify unit tests are passing:

npm run test:php -- --group 64606

Trac ticket: https://core.trac.wordpress.org/ticket/66268

Use of AI Tools

AI assistance: Yes. Claude Code was used to sync this PR with the plugin and apply the review feedback; I reviewed the changes.

Note: See TracTickets for help on using tickets.