Opened 10 years ago
Closed 10 years ago
#32226 closed enhancement (duplicate)
'get_the_posts_pagination' Filter
| Reported by: |
|
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)
Change History (4)
Note: See
TracTickets for help on using
tickets.
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();