0

I checked all wordpress xml rpc methods, but they all require post_id to get the post. How can I get a post using its title? Or, is there a rpc method to get post_id from title so that I can get the post by post_id later?

Thanks!

peter
  • 379
  • 2
  • 6
  • 16

1 Answers1

0

There doesn't seem to be a way to do it with the standard xml rpc methods in Wordpress, but thankfully there's always ways to extend it. If you install the "Extended API over XMLRPC" you can get access to all the Wordpress APIs over xml rpc (there are configuration settings to restrict this for security reasons). You can then call the get_page_by_title() API remotely to get a post by its title (pseudocode):

$xmlrpc_client->call('wpext.callWpMethod', $username, $password, 'get_page_by_title', $title, 'OBJECT', 'post');
  • 'wpext.callWpMethod' - Wordpress xml rpc method name used by the plugin for calling other WP APIs.
  • $username = valid username.
  • $password - valid password.
  • 'get_page_by_title' - the WP api to call. $title - Set to the title of the page you're looking for (not case sensitive).
  • 'OBJECT' - return type for the API. Will be returned as an associative array if 'OBJECT' specified.
  • 'post' - Post type 'post' or it will default to 'page'.

Edit: the plugin requires the first two arguments to be a valid username and password so changed above to reflect.

Ian W
  • 71
  • 1
  • 4