get_the_posts_pagination() - WordPress 函数参考中文文档

返回介绍

get_the_posts_pagination()

发布于 2017-09-11 字数2847 浏览 905 评论 0

get_the_posts_pagination( array $args = array() )

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


描述


参数

$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;
}

更新日志

Version 描述
4.1.0 Introduced.

相关函数

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' ),
    ) );
    

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!