[wp-hackers] XML-RPC add Category filter

Marko Heijnen mailing at markoheijnen.nl
Tue Oct 29 00:05:28 UTC 2013


Hey Gabriel,

There are a few tickets on http://core.trac.wordpress.org/query?status=accepted&status=assigned&status=new&status=reopened&status=reviewing&component=XML-RPC&col=id&col=summary&col=status&col=type&col=priority&col=milestone&col=component&order=priority about better filter option for wp.getPosts.
In this case http://core.trac.wordpress.org/ticket/22540 in particular.

I guess what you should have done is overwriting the method to have this or even better create a custom one from scratch that only returns the information you need.

Marko



Op 29 okt. 2013, om 00:43 heeft Gabriel Acosta <gabo.acosta624 at gmail.com> het volgende geschreven:

> 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)
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list