availability:

WPML Version: 4.0.0

description:

WPML automatically tries to redirect visitors to the canonical URL when it does find a match. This hook allows to disable this WPML functionality.

type:
filter
category:
Miscellaneous
parameters:
add_filter( 'wpml_is_redirected', 'callable $function_to_add, 10, 3 );

There are three parameters being passed to this filter:

$redirect
(bool) Boolean value to define whether or not to disable WPML canonical URL redirection actions.
$post_id
(integer) post ID
$query
(array) The WordPress query array.
hook example usage:

The following example prevents WPML canonical URL redirection for a Custom Post Type with a slug of “city”

function mytheme_do_not_redirect_city_post_type( $redirect, $post_id, $query ) {
    if ( 'city' === $query->get( 'post_type' ) ) {
       return false;
     }
    return $redirect;
    };
add_filter( 'wpml_is_redirected', 'mytheme_do_not_redirect_city_post_type', 10, 3 );