返回介绍

get_the_posts_pagination()

发布于 2017-09-11 00:37:01 字数 2845 浏览 1133 评论 0 收藏 0

get_the_posts_pagination( array $args = array() )

Retrieves a paginated navigation to next/previous set of posts, when applicable.


description


参数

$args

(array) (Optional) Default pagination arguments, see paginate_links().

  • 'screen_reader_text'
    (string) Screen reader text for navigation element. Default 'Posts navigation'.

Default value: array()


返回值

(string) Markup for pagination links.


源代码

File: wp-includes/link-template.php

function get_the_posts_pagination( $args = array() ) {
	$navigation = '';

	// Don't print empty markup if there's only one page.
	if ( $GLOBALS['wp_query']->max_num_pages > 1 ) {
		$args = wp_parse_args( $args, array(
			'mid_size'           => 1,
			'prev_text'          => _x( 'Previous', 'previous set of posts' ),
			'next_text'          => _x( 'Next', 'next set of posts' ),
			'screen_reader_text' => __( 'Posts navigation' ),
		) );

		// Make sure we get a string back. Plain is the next best thing.
		if ( isset( $args['type'] ) && 'array' == $args['type'] ) {
			$args['type'] = 'plain';
		}

		// Set up paginated links.
		$links = paginate_links( $args );

		if ( $links ) {
			$navigation = _navigation_markup( $links, 'pagination', $args['screen_reader_text'] );
		}
	}

	return $navigation;
}

更新日志

Versiondescription
4.1.0Introduced.

相关函数

Uses

  • wp-includes/link-template.php: _navigation_markup()
  • wp-includes/l10n.php: _x()
  • wp-includes/l10n.php: __()
  • wp-includes/general-template.php: paginate_links()
  • wp-includes/functions.php: wp_parse_args()

Used By

  • wp-includes/link-template.php: the_posts_pagination()

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note Contributed by Mizner
    
    // Usage Example
    $pagination = get_the_posts_pagination( array(
        'mid_size' => 2,
        'prev_text' => __( 'Newer', 'textdomain' ),
        'next_text' => __( 'Older', 'textdomain' ),
    ) );
    

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文