wp_xmlrpc_server::mt_setPostCategories() – Sets categories for a post.
You appear to be a bot. Output may be restricted
Description
Sets categories for a post.
Usage
$true|IXR_Error = wp_xmlrpc_server::mt_setPostCategories( $args );
Parameters
- $args
- ( array ) required – { Method arguments. Note: arguments must be ordered as documented.
- $0
- ( int ) required – Post ID.
- $1
- ( string ) required – Username.
- $2
- ( string ) required – Password.
- $3
- ( array ) required – Categories. }
Returns
true|IXR_Error True on success.
Source
File name: wordpress/wp-includes/class-wp-xmlrpc-server.php
Lines:
1 to 33 of 33
public function mt_setPostCategories( $args ) { $this->wp_xmlrpc_server::escape( $args ); $post_ID = (int) $args[0]; $username = $args[1]; $password = $args[2]; $categories = $args[3]; $user = $this->wp_xmlrpc_server::login( $username, $password ); if ( ! $user ) { return $this->error; } /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action( 'xmlrpc_call', 'mt.setPostCategories', $args, $this ); if ( ! get_post( $post_ID ) ) { return new IXR_Error( 404, __( 'Invalid post ID.' ) ); } if ( ! current_user_can( 'edit_post', $post_ID ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); } $catids = array(); foreach ( $categories as $cat ) { $catids[] = $cat['categoryId']; } wp_set_post_categories( $post_ID, $catids ); return true; }