# Conditionally Disabling Weglot Translation for Specific URLs

Suppose you’re facing an issue where generating PDFs is not working correctly due to Weglot's translation being applied to those URLs. In this case, instead of disabling the entire Weglot plugin, you can selectively disable its translation process for specific URLs.

```php
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;
        });
    }
}
```

**Why Use This Approach?**

* **Avoid full deactivation**: Instead of disabling the entire Weglot plugin (which affects your whole site), this solution allows you to keep Weglot active while bypassing translation only for specific scenarios.
* **Resolve conflicts efficiently**: For example, if generating PDFs or handling specific routes fails due to translations, disabling Weglot only for those URLs resolves the issue without affecting the rest of your website.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.weglot.com/wordpress/use-cases/conditionally-disabling-weglot-translation-for-specific-urls.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
