[wp-hackers] XML-RPC add Category filter

Gabriel Acosta gabo.acosta624 at gmail.com
Mon Oct 28 23:43:40 UTC 2013


Hello, I'm new to Wordpress development but experienced in PHP, I just made
a very tiny change to the Wordpress XML RPC server to fit my needs and I
think other people might benefit from it, so let me explain.

I intend to use wordpress' admin panel to create posts in a blog but I'm
displaying this posts in a site developed with Laravel Framework and
AngularJS since it fits the purpose of my client, so I'm setting a
wordpress in a subdomain and making RPC calls and that way I don't have to
interact with the site DataBase (My Boss' requirement fo course) anyway I
needed to filter the posts by category but I noticed that it is not
implemented so I made the following changes to Wordpress 3.7:

In the file: wordpress/wp-includes/class-wp-xmlrpc-server.php
On lines 1406 to 1420 it declares the filters to get a post, all I needed
to add was:

if ( isset( $filter['category'] ) )
            $query['category'] = $filter['category'];

And since it calls wp_get_recent_posts function which already supports that
key of the arguments list now I can filter my posts by category, I really
hope this helps anyone trying to solve this problem and maybe if it's ok
with the developers this change can be made to the official wordpress
source (hopefully that way I won't have to remember it either :P)


More information about the wp-hackers mailing list