[wp-xmlrpc] Handling Custom Post Types in WP 3.0 via XMLRPC

David Weiss dave at daveweiss.net
Thu Jul 8 01:06:57 UTC 2010


FYI, I wanted to use Custom Post Types and WP 3.0 in a new blog and manage
content via XMLRPC.

XMLRPC.php isn't updated to handle this, it seems.

mw_NewPost just needs a tweak to get it to work.

1993          $post_type <_variables/post_type.html> = 'post';1994
     $page_template <_variables/page_template.html> = '';1995
if ( !empty <_functions/empty.html>( $content_struct
<_variables/content_struct.html>['post_type'] ) ) {1996
if ( $content_struct <_variables/content_struct.html>['post_type'] ==
'page' ) {1997                  $cap <_variables/cap.html> = (
$publish <_variables/publish.html> ) ? 'publish_pages' :
'edit_pages';1998                  $error_message
<_variables/error_message.html> = __ <_functions/__.html>( 'Sorry, you
are not allowed to publish pages on this site.' );1999
 $post_type <_variables/post_type.html> = 'page';2000
if ( !empty <_functions/empty.html>( $content_struct
<_variables/content_struct.html>['wp_page_template'] ) )2001
           $page_template <_variables/page_template.html> =
$content_struct
<_variables/content_struct.html>['wp_page_template'];2002
} elseif ( $content_struct
<_variables/content_struct.html>['post_type'] == 'post' ) {2003
          // This is the default, no changes needed2004              }
else {2005                  // No other post_type values are allowed
here2006                  return new IXR_Error
<_classes/ixr_error.html>( 401, __ <_functions/__.html>( 'Invalid post
type.' ) );2007              }2008          }


I just edited up the if/elseif/else to take into account my custom
post type names, and set the post_type key/value to the appropriate
post type in my client.

Works fine so far.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.automattic.com/pipermail/wp-xmlrpc/attachments/20100707/6cff28b7/attachment.htm>


More information about the wp-xmlrpc mailing list