wp_link_pages_args
云策文档标注
概述
wp_link_pages_args 是一个 WordPress 过滤器钩子,用于修改分页文章页面链接的参数。它允许开发者自定义 wp_link_pages() 函数生成链接时的行为,如链接文本、格式和属性。
关键要点
- 过滤器钩子名称:wp_link_pages_args
- 作用:过滤 wp_link_pages() 函数中用于检索分页文章页面链接的参数数组
- 参数:$parsed_args,一个包含页面链接参数的数组,具体参数参考 wp_link_pages() 文档
- 常见参数包括 before、after、link_before、link_after、aria_current、next_or_number、separator、nextpagelink、previouspagelink、pagelink 和 echo
- 用法示例:通过 add_filter() 应用此钩子来修改链接参数
- 引入版本:WordPress 3.0.0
代码示例
$parsed_args = apply_filters( 'wp_link_pages_args', $parsed_args );注意事项
- 参数 $parsed_args 是一个数组,需确保修改后返回有效数组
- 此钩子主要用于自定义分页链接的显示,如更改文本或添加 HTML 结构
- 相关函数:wp_link_pages(),用于输出分页链接列表
原文内容
Filters the arguments used in retrieving page links for paginated posts.
Parameters
$parsed_argsarray-
An array of page link arguments. See wp_link_pages() for information on accepted arguments.
More Arguments from wp_link_pages( … $args )
Array or string of default arguments.
beforestringHTML or text to prepend to each link. Default is<p> Pages:.afterstringHTML or text to append to each link. Default is</p>.link_beforestringHTML or text to prepend to each link, inside the<a>tag.
Also prepended to the current item, which is not linked. Default empty.link_afterstringHTML or text to append to each Pages link inside the<a>tag.
Also appended to the current item, which is not linked. Default empty.aria_currentstringThe value for the aria-current attribute. Possible values are'page','step','location','date','time','true','false'. Default is'page'.next_or_numberstringIndicates whether page numbers should be used. Valid values are number and next. Default is'number'.separatorstringText between pagination links. Default is ‘ ‘.nextpagelinkstringLink text for the next page link, if available. Default is ‘Next Page’.previouspagelinkstringLink text for the previous page link, if available. Default is ‘Previous Page’.pagelinkstringFormat string for page numbers. The % in the parameter string will be replaced with the page number, so ‘Page %’ generates “Page 1”, “Page 2”, etc.
Defaults to'%', just the page number.echoint|boolWhether to echo or not. Accepts1|trueor0|false. Default1|true.
Source
$parsed_args = apply_filters( 'wp_link_pages_args', $parsed_args );
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |