钩子文档

wp_link_pages

💡 云策文档标注

概述

wp_link_pages 是一个 WordPress 过滤器,用于修改分页文章页面链接的 HTML 输出。它允许开发者自定义链接的格式、文本和属性。

关键要点

  • 过滤器名称:wp_link_pages
  • 参数:$output(HTML 输出字符串)和 $args(参数数组或字符串)
  • 主要用途:过滤分页链接的 HTML,支持自定义 before、after、link_before、link_after、aria_current、next_or_number、separator、nextpagelink、previouspagelink、pagelink 和 echo 等参数
  • 相关函数:wp_link_pages(),用于生成分页链接列表
  • 引入版本:WordPress 3.6.0

📄 原文内容

Filters the HTML output of page links for paginated posts.

Parameters

$outputstring
HTML output of paginated posts’ page links.
$argsarray|string
An array or query string of arguments. See wp_link_pages() for information on accepted arguments.

More Arguments from wp_link_pages( … $args )

Array or string of default arguments.

  • before string
    HTML or text to prepend to each link. Default is <p> Pages:.
  • after string
    HTML or text to append to each link. Default is </p>.
  • link_before string
    HTML or text to prepend to each link, inside the <a> tag.
    Also prepended to the current item, which is not linked. Default empty.
  • link_after string
    HTML 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_current string
    The value for the aria-current attribute. Possible values are 'page', 'step', 'location', 'date', 'time', 'true', 'false'. Default is 'page'.
  • next_or_number string
    Indicates whether page numbers should be used. Valid values are number and next. Default is 'number'.
  • separator string
    Text between pagination links. Default is ‘ ‘.
  • nextpagelink string
    Link text for the next page link, if available. Default is ‘Next Page’.
  • previouspagelink string
    Link text for the previous page link, if available. Default is ‘Previous Page’.
  • pagelink string
    Format 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.
  • echo int|bool
    Whether to echo or not. Accepts 1|true or 0|false. Default 1|true.

Source

$html = apply_filters( 'wp_link_pages', $output, $args );

Changelog

Version Description
3.6.0 Introduced.