Skip to content

title property is missing from WP_Query class documentation #1371

Closed

Description

Issue Description

The documentation for the WP_Query class is missing the title parameter.

URL of the Page with the Issue

https://developer.wordpress.org/reference/classes/wp_query/

Section of Page with the issue

I think this would best fit under the "Post & Page Parameters" section.

Why is this a problem?

WordPress 4.4 added the parameter to WP_Query to retrieve posts by their title (post_title), however it is not currently in the documentation for the class. It's especially note-worthy that the parameter is title and not post_title, and also that it must be an exact match (the generated SQL clause uses equals, for example: 'post_title' = 'Hello World!')

Code where this parameter is applied: https://github.com/WordPress/wordpress-develop/blob/6.4/src/wp-includes/class-wp-query.php#L2134

Suggested Fix

In the "Post & Page Parameters" section, at the end of the ul we can add:

  • title (string) – use post title. Retrieve posts by post_title (available since version 4.4).

Then we can add an example, within the same section:

Display posts with a specific title:

$query = new WP_Query( array( 'title' => 'Hello World!' ) );

Note the title must be an exact match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions