6.7 load_theme_textdomain desn’t work | WordPress.org

[ad_1]

To make translations work in WordPress 6.7, you need to update how you’re loading them. Here’s what you should do:

1. Update load_theme_textdomain Function

Since WordPress 6.7 now expects translations to be in wp-content/languages/themes/, you should update your load_theme_textdomain call to reflect this change. You can override the default path like this:

function my_theme_setup() {
load_theme_textdomain('gutrs', WP_LANG_DIR . '/themes');
}
add_action('after_setup_theme', 'my_theme_setup');

This will tell WordPress to look for translations in the wp-content/languages/themes/ directory instead of the theme’s languages folder.

2. Move Your Translation Files

Move your translation files from your theme’s /languages/ folder to the following directory in your WordPress installation:

wp-content/languages/themes/gutrs-{locale}.mo

For example, if you’re using French translations, the file would be:

wp-content/languages/themes/gutrs-fr_FR.mo

3. This centralizes your translations and ensures they work with the new system in WordPress 6.7.3. Fallback for Development Environments (Optional)

If you still want to keep using the theme’s languages folder for translations (for development purposes or testing), you can keep your current setup and also explicitly specify the path to the theme’s folder:

function my_theme_setup() {
load_theme_textdomain('gutrs', get_template_directory() . '/languages');
load_theme_textdomain('gutrs', WP_LANG_DIR . '/themes'); // Fallback to global folder
}
add_action('after_setup_theme', 'my_theme_setup');

This ensures that WordPress will check both the theme’s local languages folder and the central wp-content/languages/themes/ directory.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer