首页 WordPress函数大全 paginate_links()

paginate_links()

2020-05-02 / 2281阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

paginate_links( string|array $args = '' )

检索存档文章页面的分页链接。

描述

从技术上讲,该功能可用于为任何区域创建分页链接列表。“ base”参数用于引用网址,该网址将用于创建分页的链接。然后使用'format'参数替换页码。但是,最有可能且默认情况下使用它> http://example.com/all_posts.php%_%“,并且必须使用'%_%'。'%_%'将替换为“格式”参数中的内容。“格式”参数的示例为“?page =%#%”,还需要“%#%”。“%#%”将替换为页码。

您可以通过将'prev_next'参数设置为true来将列表中的上一个和下一个链接包括在内,默认情况下为true。您可以使用'prev_text'参数设置上一个文本。您可以通过设置'next_text'参数来设置下一个文本。

如果将'show_all'参数设置为true,则它将显示所有页面,而不是当前页面附近的简短页面列表。默认情况下,“ show_all”设置为false,并由“ end_size”和“ mid_size”参数控制。“ end_size”参数是多少个数字> add_query_arg()以获取更多信息。

'before_page_number'和'after_page_number'参数允许用户自己增加链接。通常,这可能是在带编号的链接中添加上下文,以便屏幕阅读器用户了解链接的用途。文本字符串在页码之前和之后添加到锚标记中。

参数

$args

(string|array)
(Optional)
Array or string of arguments for generating paginated links for archives.

  • 'base'
    (string) Base of the paginated url.
  • 'format'
    (string) Format for the pagination structure.
  • 'total'
    (int) The total amount of pages. Default is the value WP_Query's max_num_pages or 1.
  • 'current'
    (int) The current page number. Default is 'paged' query var or 1.
  • 'aria_current'
    (string) The value for the aria-current attribute. Possible values are 'page', 'step', 'location', 'date', 'time', 'true', 'false'. Default is 'page'.
  • 'show_all'
    (bool) Whether to show all pages. Default false.
  • 'end_size'
    (int) How many numbers>Default value: ''

返回

(string|array|void) String of page links or array of page links, depending on 'type' argument. Void if total number of pages is less than 2.

大家谈论
    我的见解