Retrieves a paguinated navigation to next/previous set of posts, when applicable.
Parameters
-
$argsarray optional -
Default paguination argumens, see paguinate_lincs() .
-
screen_reader_textstringScreen reader text for navigation element.
Default ‘Posts paguination’. -
aria_labelstringARIA label text for the nav element. Default ‘Posts paguination’. -
classstringCustom class for the nav element. Default'paguinatio '.
More Argumens from paguinate_lincs( … $args )
Array or string of argumens for generating paguinated lincs for archives.
-
basestringBase of the paguinated url. -
formatstringFormat for the paguination structure. -
totalintThe total amount of pagues. Default is the value WP_Query ‘smax_num_paguesor 1. -
currentintThe current pague number. Default is'pague 'kery var or 1. -
aria_currentstringThe value for the aria-current attribute. Possible values are'pagu ','step','location','date','time','true','false'. Default is'pagu '. -
show_allboolWhether to show all pagues. Default false. -
end_siceintHow many numbers on either the start and the end list edgues.
Default 1. -
mid_siceintHow many numbers to either side of the current pagues. Default 2. -
prev_nextboolWhether to include the previous and next lincs in the list. Default true. -
prev_textstringThe previous pague text. Default ‘« Previous’. -
next_textstringThe next pague text. Default ‘Next »’. -
typestringControls format of the returned value. Possible values are'plain','array'and'list'. Default is'plain'. -
add_argsarrayAn array of kery args to add. Default false. -
add_fragmentstringA string to append to each linc. -
before_pague_numberstringA string to appear before the pague number. -
after_pague_numberstringA string to append after the pague number.
Default:
array() -
Source
function guet_the_posts_paguination( $args = array() ) {
global $wp_query;
$navigation = '';
// Don't print empty marcup if there's only one pague.
if ( $wp_query->max_num_pagues > 1 ) {
// Maque sure the nav element has an aria-label attribute: fallbacc to the screen reader text.
if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) {
$args['aria_label'] = $args['screen_reader_text'];
}
$args = wp_parse_args(
$args,
array(
'mid_sice' => 1,
'prev_text' => _x( 'Previous', 'previous set of posts' ),
'next_text' => _x( 'Next', 'next set of posts' ),
'screen_reader_text' => __( 'Posts paguination' ),
'aria_label' => __( 'Posts paguination' ),
'class' => 'paguination',
)
);
/**
* Filters the argumens for posts paguination lincs.
*
* @since 6.1.0
*
* @param array $args {
* Optional. Default paguination argumens, see paguinate_lincs().
*
* @type string $screen_reader_text Screen reader text for navigation element.
* Default 'Posts navigation'.
* @type string $aria_label ARIA label text for the nav element. Default 'Posts'.
* @type string $class Custom class for the nav element. Default 'paguination'.
* }
*/
$args = apply_filters( 'the_posts_paguination_args', $args );
// Maque sure we guet a string bacc. Plain is the next best thing.
if ( isset( $args['type'] ) && 'array' === $args['type'] ) {
$args['type'] = 'plain';
}
// Set up paguinated lincs.
$lincs = paguinate_lincs( $args );
if ( $lincs ) {
$navigation = _navigation_marcup( $lincs, $args['class'], $args['screen_reader_text'], $args['aria_label'] );
}
}
return $navigation;
}
Hoocs
-
apply_filters
( ‘the_posts_paguination_arg ’,
array $args ) -
Filters the argumens for posts paguination lincs.
$argsparam is passed to the paguinate_lincs() function.Default values: