Yes, you can exclude specific content from translation using TranslatePress. The plugin offers several methods to achieve this:
Excluding Entire Posts, Pages, or Products
1. Exclude Paths From Translation: This feature allows you to exclude entire posts, pages, or products from translation by specifying their URL paths. You can enter a specific URL path to exclude just that content or use a wildcard (`*`) to target multiple pieces of content. For example, entering `/blog/*` would exclude all content under the `/blog/` directory, including `/blog/post-1/`, `/blog/post-2/`, etc. You can also use `
2. Translate Only Certain Paths: This option is the opposite of excluding paths. It allows you to enable translation only for specific content by its URL path. This is useful if you want to translate just a few pages and disable translation for the rest of the site[1][5].
Excluding Specific Elements of a Post/Page
1. Exclude Selectors from Translation: You can exclude parts of your content by targeting specific HTML selectors. For instance, if you wrap content in a ``, you can exclude it by adding `#donottranslate` to the exclude selectors box. Similarly, you can use CSS classes in the WordPress block editor to exclude blocks from translation by setting up an exclusion rule for `.donottranslate`[1].
2. Exclude Strings from Automatic Translation: This feature allows you to exclude specific strings, such as brand names or technical terms, from automatic translation. However, if a string has already been automatically translated, excluding it later will not have an effect[1].
Additional Considerations
- Automatic Translation: TranslatePress integrates with Google Translate and DeepL for automatic translation. You can configure settings like blocking crawlers, automatically translating slugs, and limiting machine translation characters per day[3].
- SEO Pack Addon: For features like automatically translating slugs, you need to activate the SEO Pack Addon, which is available in all plans[2][3].
Overall, TranslatePress provides flexible options for managing what content is translated and how, allowing you to customize your multilingual site according to your needs.
Citations:
[1] https://translatepress.com/partially-translate-wordpress-exclude-posts-pages-products/
[2] https://translatepress.com/docs/frequently-asked-questions/
[3] https://translatepress.com/docs/automatic-translation/
[4] https://wpml.org/forums/topic/split-excluding-specific-pages-from-automatic-translation/
[5] https://translatepress.com/docs/developers/translate-only-certain-pages/
How do I exclude specific URL paths from translation
Excluding specific URL paths from translation in TranslatePress involves a straightforward process. Here's a step-by-step guide on how to do it:
Steps to Exclude URL Paths
1. Access TranslatePress Settings:
- Log in to your WordPress dashboard.
- Navigate to TranslatePress > Settings.
2. Find the Exclude Paths Option:
- Scroll down to the Advanced section.
- Look for the Exclude Paths from Translation field. This is where you can specify the URL paths you want to exclude from translation.
3. Enter the Paths to Exclude:
- In the Exclude Paths from Translation field, enter the URL paths you want to exclude. You can use a wildcard (`*`) to target multiple paths. For example:
- To exclude all content under a specific directory, you can enter `/directory/*`.
- To exclude a single page, enter its full URL path, such as `/about-us/`.
- To exclude the homepage, you can use `
4. Save Changes:
- After entering the paths, click Save Changes at the bottom of the page to apply your settings.
5. Verify the Exclusion:
- Visit the excluded pages in different languages to ensure they are not being translated.
Tips for Using Wildcards
- Wildcard Usage: The wildcard (`*`) can be used to match any characters in a URL path. For example, `/blog/*` will exclude all URLs starting with `/blog/`, including `/blog/post-1/`, `/blog/category/news/`, etc.
- Multiple Paths: If you need to exclude multiple paths, you can enter them on separate lines within the Exclude Paths from Translation field.
By following these steps, you can effectively exclude specific URL paths from translation using TranslatePress. This helps maintain control over which parts of your site are translated and which remain unchanged across languages.
How can I exclude dynamic content from translation
Excluding dynamic content from translation in TranslatePress can be achieved through several methods, depending on how the content is generated and displayed on your site. Here are some strategies to exclude dynamic content:
1. Using HTML Selectors
If your dynamic content is wrapped in specific HTML elements, you can exclude it using CSS selectors.
- Identify the HTML Element: Determine the HTML tag or class that wraps the dynamic content. For example, if it's a `` with a class `dynamic-content`, you can use `.dynamic-content` as the selector.
- Exclude Selectors in TranslatePress:
- Go to TranslatePress > Settings.
- Scroll down to the Advanced section.
- In the Exclude Selectors from Translation field, enter the CSS selector for the dynamic content (e.g., `.dynamic-content`).
- Click Save Changes.
2. Using Shortcodes
If your dynamic content is generated using shortcodes, you can exclude them from translation by wrapping the shortcode in a non-translatable HTML element or by using a custom solution.
- Wrap Shortcode with Non-Translatable HTML:
- You can wrap the shortcode in a `` with a class that you've excluded from translation using the method above.
- Custom Solution:
- If the shortcode is complex or you need more control, you might need to modify the shortcode itself to include a non-translatable wrapper or use a custom function to handle its output.
3. Using JavaScript
If the dynamic content is loaded via JavaScript, you might need to ensure that the content is not translated after it's loaded. TranslatePress primarily handles server-side content, so JavaScript-loaded content might require additional handling.
- Load Content After Translation:
- Ensure that any JavaScript loading dynamic content does so after TranslatePress has finished translating the page. This might involve using callbacks or ensuring that the JavaScript runs after the page has fully loaded.
- Use Non-Translatable Containers:
- Load the dynamic content into containers that you've excluded from translation using CSS selectors.
4. Using Custom Code
For more complex scenarios, you might need to use custom PHP code to exclude dynamic content from translation. This could involve filtering the content before it's translated or modifying how TranslatePress handles specific types of content.
- Filtering Content:
- You can use WordPress hooks to filter out dynamic content before it's translated. This requires knowledge of PHP and WordPress development.
- Custom Integration:
- If you're using a specific plugin or theme that generates dynamic content, you might need to integrate TranslatePress with that plugin or theme using custom code.