常用函数-get_category_by_path()

0条评论

常用函数-get_category_by_path()

说明

按含有类别缩略名的URL检索类别。

解析$category参数以获取类别缩略名。

搜索子路径并将其返回。如果$full_match设为false,找不到匹配路径时则返回符合缩略名的第一个类别。如果$full_match未设为false,返回空值。

出错时也可能返回WP_Error对象。使用该函数时注意检查对象。

用法

<?php get_category_by_path( $category_path, $full_match, $output ) ?>

参数

$category_path

(字符)(必需)含有类别缩略名的URL

默认值:空

$full_match

(布尔值)(可选)是否应匹配完全路径

默认值:true

$output

(字符)(可选)常量OBJECT,ARRAY_A, 或 ARRAY_N

默认值:OBJECT

返回的值

(空 | 对象 | 数组)

出错时返回Null。返回的类型取决于$output的值。

示例

注释

修改记录

自2.1.0版本后

源文件

get_category_by_path() 位于 wp-includes/category.php中。

相关资源

发表新评论

此内容将保密,不会被其他人看见。
  • 自动将网址与电子邮件地址转变为链接。
  • 允许HTML标签:<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • 自动断行和分段。

更多关於格式化选项的信息

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.