add_filter( 'wpml_is_redirected', 'callable $function_to_add, 10, 3 );
- Type
- filter
- Category
- Miscellaneous
- 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.
Arguments
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.
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 );
Related hooks
icl_ls_languages, wpml_sync_custom_field_copied_value, wpml_ls_enable_ajax_navigation, wpml_element_type, wpml_setting, wpml_sub_setting, wpml_exclude_post_from_auto_translate, wpml_forms_config_ninja-forms, wpml_forms_config_wpforms, wpml_tf_feedback_open_link