wp_page_menu
云策文档标注
概述
wp_page_menu 是一个 WordPress 过滤器,用于修改基于页面的菜单的 HTML 输出。它允许开发者通过 apply_filters 钩子自定义菜单的呈现方式。
关键要点
- 过滤器名称:wp_page_menu,用于过滤页面菜单的 HTML 输出字符串。
- 参数:接受 $menu(HTML 输出字符串)和 $args(参数数组),参数详情可参考 wp_page_menu() 函数。
- 相关函数:与 wp_page_menu() 函数紧密关联,用于显示或检索页面列表。
- 引入版本:WordPress 2.7.0。
代码示例
$menu = apply_filters( 'wp_page_menu', $menu, $args );
原文内容
Filters the HTML output of a page-based menu.
Description
See also
Parameters
$menustring-
The HTML output.
$argsarray-
An array of arguments. See wp_page_menu() for information on accepted arguments.
More Arguments from wp_page_menu( … $args )
Array or string of arguments to retrieve pages.
child_ofintPage ID to return child and grandchild pages of. Note: The value of$hierarchicalhas no bearing on whether$child_ofreturns hierarchical results. Default 0, or no restriction.sort_orderstringHow to sort retrieved pages. Accepts'ASC','DESC'. Default'ASC'.sort_columnstringWhat columns to sort pages by, comma-separated. Accepts'post_author','post_date','post_title','post_name','post_modified','menu_order','post_modified_gmt','post_parent','ID','rand','comment*count'.
'post*'can be omitted for any values that start with it.
Default'post_title'.hierarchicalboolWhether to return pages hierarchically. If false in conjunction with$child_ofalso being false, both arguments will be disregarded.
Default true.excludeint[]Array of page IDs to exclude.includeint[]Array of page IDs to include. Cannot be used with$child_of,$parent,$exclude,$meta_key,$meta_value, or$hierarchical.meta_keystringOnly include pages with this meta key.meta_valuestringOnly include pages with this meta value. Requires$meta_key.authorsstringA comma-separated list of author IDs.parentintPage ID to return direct children of. Default -1, or no restriction.exclude_treestring|int[]Comma-separated string or array of page IDs to exclude.numberintThe number of pages to return. Default 0, or all pages.offsetintThe number of pages to skip before returning. Requires$number.
Default 0.post_typestringThe post type to query. Default'page'.post_statusstring|arrayA comma-separated list or array of post statuses to include.
Default'publish'.
Source
$menu = apply_filters( 'wp_page_menu', $menu, $args );
Changelog
| Version | Description |
|---|---|
| 2.7.0 | Introduced. |