Skip to main content

Redirections

1. Change number of redirections to process at once

/**
* Allow developers to change number of redirections to process at once.
*
* @param int $number
*/
add_filter( 'rank_math/redirections/pastedContent', function( $number ) {
return $number;
});

2. Filter to disable appending the query string in the redirection URL

/**
* Disable appending the query string in the redirection URL.
*
* @param bool $value Enable or disable appending the query string.
* @param array $matched Matched redirection.
*/
add_filter( 'rank_math/redirection/add_query_string', function($value, $matched) {
return false;
}, 10, 2 );

3. Filter to disable custom product redirection

Use this filter to disable custom product redirection when the option Remove base or Remove category base is enabled for WooCommerce products.

/**
* Filter to disable custom product redirection.
*/
add_filter( 'rank_math/woocommerce/product_redirection', '__return_false' );

4. Filter to strip leading slashes for Regex redirections

 * Filter to strip leading slashes for Regex redirections
*/
add_filter( 'rank_math/redirection/get_clean_pattern', function( $cleaned, $pattern, $comparison ) {
if ( $comparison === 'regex' ) {
$cleaned = '@' . stripslashes( ltrim( $pattern, '/' ) ) . '@';
}
return $cleaned;
}, 10, 3 );