[wp-trac] [WordPress Trac] #64813: Docs: Fix `@param` type for `get_posts()` and other functions using `wp_parse_args()`

WordPress Trac noreply at wordpress.org
Thu Mar 5 18:37:17 UTC 2026


#64813: Docs: Fix `@param` type for `get_posts()` and other functions using
`wp_parse_args()`
-------------------------------+--------------------------
 Reporter:  rodrigosprimo      |       Owner:  westonruter
     Type:  defect (bug)       |      Status:  accepted
 Priority:  normal             |   Milestone:  7.0
Component:  Posts, Post Types  |     Version:
 Severity:  normal             |  Resolution:
 Keywords:  has-patch commit   |     Focuses:  docs
-------------------------------+--------------------------
Changes (by westonruter):

 * keywords:  has-patch => has-patch commit
 * component:  General => Posts, Post Types


Comment:

 Replying to [ticket:64813 rodrigosprimo]:
 > Should those be addressed as well?
 > ...
 > === Should `object` be included? ===

 Just seeing this part of the ticket after reviewing the PR.

 Yes, `get_posts()` works when an `object` is passed thanks to
 `wp_parse_args()`. However, I'm not sure we want to necessarily encourage
 that. Just because you can pass something doesn't mean you should. The
 same could be said for `string`.

 But I do see quite a few plugins passing a string to `get_posts()`:
 https://wpdirectory.net/search/01KJZMCFA2DP2B22MGFCQMZ5DN

 So that seems clearly like it should be documented as being supported.

 As for the other functions listed, it seems strings are extremely rarely
 passed: https://wpdirectory.net/search/01KJZMG5EH7HXX70XR28CV3H53

 The only example (barely) is `wp_get_recent_posts()`.

 So I think sticking just with adding `string` as an allowed type for the
 param for `get_posts()` is good for now.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64813#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list