bbp_make_first_page_canonical( string $pagination_links = '' )

Remove the first-page from a pagination links result set, ensuring that it points to the canonical first page URL.


Description Description

This is a bit of an SEO hack, to guarantee that the first page in a loop will never have pagination appended to the end of it, regardless of what the other functions have decided for us.


Parameters Parameters

$pagination_links

(Optional) The HTML links used for pagination

Default value: ''


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/core/abstraction.php

function bbp_make_first_page_canonical( $pagination_links = '' ) {

	// Default value
	$retval = $pagination_links;

	// Remove first page from pagination
	if ( ! empty( $pagination_links ) ) {
		$retval = bbp_use_pretty_urls()
			? str_replace( bbp_get_paged_slug() . '/1/', '', $pagination_links )
			: preg_replace( '/&paged=1(?=[^0-9])/m', '', $pagination_links );
	}

	// Filter & return
	return apply_filters( 'bbp_make_first_page_canonical', $retval, $pagination_links );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.