paginate_links │ filter-hook │ WP 3.0.0

Allows changing the URL of each pagination link created by the paginate_links() function.

The filter is applied separately to the previous, next, and numbered page links. The current page and the link ellipses do not contain a URL, so they are not passed through this filter.

After applying the filter, WordPress cleans the URL with esc_url().

To change the complete HTML markup of the pagination, use the paginate_links_output filter.

Usage

add_filter( 'paginate_links', 'wp_kama_paginate_links_filter' );

/**
 * Function for `paginate_links` filter-hook.
 * 
 * @param string $link The paginated link URL.
 *
 * @return string
 */
function wp_kama_paginate_links_filter( $link ){
	// filter...
	return $link;
}
$link(string)
URL of an individual pagination page.

Examples

#1 Add a GET parameter to all pagination links

add_filter( 'paginate_links', 'wp_kama_add_layout_to_paginate_links' );

function wp_kama_add_layout_to_paginate_links( $link ) {
	return add_query_arg( 'layout', 'grid', $link );
}

Changelog

Since 3.0.0 Introduced.

Where the hook is called

paginate_links()
paginate_links
wp-includes/general-template.php 5013
esc_url( apply_filters( 'paginate_links', $link ) ),
wp-includes/general-template.php 5039
esc_url( apply_filters( 'paginate_links', $link ) ),
wp-includes/general-template.php 5063
esc_url( apply_filters( 'paginate_links', $link ) ),

Where the hook is used in WordPress

Usage not found.