从XMLRPC XML中检索帖子类别。
原型
xmlrpc_getpostcategory( string $content )
描述
如果未找到category元素,则将使用默认的帖子类别。然后返回类型是$ post_default_category。如果找到类别,那么它将始终是一个数组。
参数
$content
(string)
(Required)
XMLRPC XML请求内容
返回值
(string|array)
类别列表或类别名称。
源文件
路径:wp-includes/functions.php
<?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;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/xmlrpc_getpostcategory/