一、get_categories的涵义

1.1.该函数获取本网站的分类对象或限定条件的分类对象

1.1.1.不加参数,就是获取所有分类对象。

1.1.2.加参数,就是获取指定条件的对象。参数表示限定条件

二、get_categories的常用参数

2.1.关于参数是个数组。

2.1.1.参数是个数组。

2.1.2.数组中有很多指定的键值。

2.2.该数组参数的键值。

2.2.1.‘taxonomy’(string|array) Taxonomy name, or array of taxonomies, to which results should be limited.(值的类型为字符串或数组)。它表示用分类的类型名称来限制查找的分类。

2.2.2.‘orderby’。(string) Field(s) to order terms by. Accepts term fields (‘name’, ‘slug’, ‘term_group’, ‘term_id’, ‘id’, ‘description’, ‘parent’)Defaults to ‘name’.(值为字符串类型)。它表示按什么字段来进行排序。允许的字段有 (‘name’名称, ‘slug’别名, ‘term_group’分类组, ‘term_id’分类id, ‘id’该分类的id, ‘description’该分类的描述, ‘parent’按父级),默认值为name.

2.2.3.‘order’。(string) Whether to order terms in ascending or descending order. Accepts ‘ASC’ (ascending) or ‘DESC’ (descending). Default ‘ASC’.值为字符串类型)。表示按升序还是按降序来排序。只有两个值ASC表示升序,DESC表示降序。

2.2.4.‘include’。(array|string) Array or comma/space-separated string of term ids to include. Default empty array.(值为数组或字符串)表示指定分类id的分类对象的分类限制。默认为空数组。

2.2.5.‘exclude’。(array|string) Array or comma/space-separated string of term ids to exclude. If $include is non-empty, $exclude is ignored. Default empty array.(值为数组或字符串)表示排除指定分类id的分类对象的分类限制。默认为空数组

2.2.6.‘number’。(int|string) Maximum number of terms to return. Accepts ”|0 (all) or any positive number. Default ”|0 (all). Note that $number may not return accurate results when coupled with $object_ids. See #41796 for details.(值为整数或字符串)表示查找到的分类对象的数量最大值。

2.2.7.‘parent’。(int|string) Parent term ID to retrieve direct-child terms of.(值为整数或字符串)表示父级分类为指定id或别名的所有分类子对象。

三、get_categories的应用

3.1.通常被用于显示指定的分类列表

3.1.1.比如说指定父分类的所有子分类。

3.1.2.分类列表中包含有分类标题,分类包含的文章数等等。

博主联系方式:

  • 微信:34419369
  • QQ: 34419369
  • 公众号:前方录
  • 有什么不懂的地方欢迎联系我,帮到你是我会很开心

Leave a Reply

邮箱地址不会被公开。 必填项已用*标注