WordPress.org

Make WordPress Core

Opened 17 months ago

Last modified 12 months ago

#25406 new enhancement

XMLRPC wp_getPosts $filter argument should support more values

Reported by: wordpressplugindeveloper Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.8
Component: XML-RPC Keywords: needs-patch dev-feedback
Focuses: Cc:

Description

Although "see get_posts() for more on $filter values" is written in the doc, it actually supports
'post_type', 'post_status', 'number', 'offset', 'orderby', and 'order' only, and there is one hidden value 's' that didn't mention in the doc.

Currently, the $filter argument is handled by function wp_getPosts like this:

$query = array();
if ( isset( $filter['offset'] ) )
     $query['offset'] = absint( $filter['offset'] );
....
wp_get_recent_posts( $query );

I think it'd be better if you can use get_posts() instead and simply pass $filter as its argument.

just my 2 cents though.

Change History (1)

comment:1 @maxcutler12 months ago

  • Keywords dev-feedback added

That @see line that you quoted is meant as a modifier on the paragraph above:

The optional $filter parameter modifies the query used to retrieve posts.
Accepted keys are 'post_type', 'post_status', 'number', 'offset', 'orderby', and 'order'.

You're right that there's a doc bug that the s filter is missing both in code and in the Codex, that probably deserves a simple patch.

With regards to the suggestion to pass through $filter to wp_get_recent_posts, I think the core devs had some reservations about that approach when we added this in 3.4. It would be nice to have more filter parameters for richer querying, but there might have been security/compatibility/performance concerns that made us not do this originally.

Note: See TracTickets for help on using tickets.