Conditionally Disabling Weglot Translation for Specific URLs
When using Weglot on your website, you might occasionally encounter issues where its translation processes interfere with certain functionalities, like generating PDFs or handling custom endpoints. In
add_action('init', 'conditionally_apply_weglot_translation');
function conditionally_apply_weglot_translation() {
$current_url = $_SERVER['REQUEST_URI'];
// Check if the current URL contains 'front-end'
if (strpos($current_url, 'front-end') !== false) {
// Disable Weglot translation for this specific request
add_filter('weglot_active_translation_before_process', function() {
return false;
});
}
}Last updated