add_filter( 'wpml_is_redirected', 'callable $function_to_add, 10, 3 );
- 类型
- filter
- 类别
- 杂项
- WPML 版本
- 4.0.0
说明
当找到匹配项时,WPML 会自动尝试将访问者重定向到规范 URL。此钩子允许禁用此 WPML 功能。
参数
传递给此过滤器的参数有三个:- $redirect
- (bool) 布尔值,用于定义是否禁用 WPML 规范 URL 重定向操作。
- $post_id
- (integer) 文章 ID
- $query
- (array) WordPress 查询数组。
使用示例
以下示例可防止对别名为“city”的自定义文章类型进行 WPML 规范 URL 重定向
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 );
相关钩子
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