xmlrpc_getpostcategory() WordPress Function

The xmlrpc_getpostcategory() function is used to get a list of categories for a given post. This function is used by the XML-RPC interface to get information about a post.

xmlrpc_getpostcategory( string $content ) #

Retrieve the post category or categories from XMLRPC XML.


Description

If the category element is not found, then the default post category will be used. The return type then would be what $post_default_category. If the category is found, then it will always be an array.


Top ↑

Parameters

$content

(string)(Required)XMLRPC XML Request content


Top ↑

Return

(string|array) List of categories or category name.


Top ↑

Source

File: wp-includes/functions.php

function xmlrpc_getpostcategory( $content ) {
	global $post_default_category;
	if ( preg_match( '/<category>(.+?)<\/category>/is', $content, $matchcat ) ) {
		$post_category = trim( $matchcat[1], ',' );
		$post_category = explode( ',', $post_category );
	} else {
		$post_category = $post_default_category;
	}
	return $post_category;
}


Top ↑

Changelog

Changelog
VersionDescription
0.71Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More