WordPress at a glance
function is not described

wp_xmlrpc_server::mt_getPostCategories() public WP 1.5.0

Retrieve post categories.

{} It's a method of the class: wp_xmlrpc_server{}

Hooks from the method
Return

Array/IXR_Error.

Usage

$wp_xmlrpc_server = new wp_xmlrpc_server();
$wp_xmlrpc_server->mt_getPostCategories( $args );
$args(array) (required)

Method arguments. Note: arguments must be ordered as documented.

  • post_ID(int)

  • username(string)

  • password(string)

Changelog

Since 1.5.0 Introduced.

Code of wp_xmlrpc_server::mt_getPostCategories() WP 5.5.3

<?php
public function mt_getPostCategories( $args ) {
	$this->escape( $args );

	$post_ID  = (int) $args[0];
	$username = $args[1];
	$password = $args[2];

	$user = $this->login( $username, $password );
	if ( ! $user ) {
		return $this->error;
	}

	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.' ) );
	}

	/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
	do_action( 'xmlrpc_call', 'mt.getPostCategories' );

	$categories = array();
	$catids     = wp_get_post_categories( intval( $post_ID ) );
	// First listed category will be the primary category.
	$isPrimary = true;
	foreach ( $catids as $catid ) {
		$categories[] = array(
			'categoryName' => get_cat_name( $catid ),
			'categoryId'   => (string) $catid,
			'isPrimary'    => $isPrimary,
		);
		$isPrimary    = false;
	}

	return $categories;
}