Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#32226 closed enhancement (duplicate)

'get_the_posts_pagination' Filter

Reported by: ixkaito's profile ixkaito Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.1
Component: Permalinks Keywords: has-patch
Focuses: template Cc:

Description

Apply filters before returning $navigation to easily customize get_the_posts_pagination().

For example: removing \n in the markup.

function my_get_the_post_pagination( $navigation, $links, $args ) {
	$links = str_replace("\n", '', $links);
	if ( $links ) {
		$navigation = _navigation_markup( $links, 'pagination', $args['screen_reader_text'] );
	}
	return $navigation;
}
add_filter( 'get_the_post_pagination', 'my_get_the_post_pagination', 10, 3 );

the_posts_pagination();

Attachments (1)

32226.diff (352 bytes) - added by ixkaito 10 years ago.

Download all attachments as: .zip

Change History (4)

@ixkaito
10 years ago

#1 @ixkaito
10 years ago

I made a typo in the sample code. The correct one is the following.

function my_get_the_posts_pagination( $navigation, $links, $args ) {
	$links = str_replace("\n", '', $links);
	if ( $links ) {
		$navigation = _navigation_markup( $links, 'pagination', $args['screen_reader_text'] );
	}
	return $navigation;
}
add_filter( 'get_the_posts_pagination', 'my_get_the_posts_pagination', 10, 3 );

the_posts_pagination();

#2 @ixkaito
10 years ago

  • Keywords has-patch added

#3 @obenland
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #31315.

Ideally that would be handled in _navigation_markup() or a custom callback.

Note: See TracTickets for help on using tickets.