Title: problem with a subdomain
Last modified: July 24, 2026

---

# problem with a subdomain

 *  [sacconi](https://wordpress.org/support/users/sacconi/)
 * (@sacconi)
 * [2 weeks, 1 day ago](https://wordpress.org/support/topic/problem-with-a-subdomain/)
 * Despite of this code:
 *     ```wp-block-code
       `define( 'WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST']);define( 'WP_HOME', 'https://' . $_SERVER['HTTP_HOST']);if ('de.' == substr( $_SERVER['HTTP_HOST'], 0, 3 )) {define ('WPLANG', 'de_DE');}if ('en.' == substr( $_SERVER['HTTP_HOST'], 0, 3 )) {define ('WPLANG', 'en_EN');}if ('fr.' == substr( $_SERVER['HTTP_HOST'], 0, 3 )) {define ('WPLANG', 'fr_FR');}if ('es.' == substr( $_SERVER['HTTP_HOST'], 0, 3 )) {define ('WPLANG', 'es_ES');
       ```
   
 * Only the english and the german versions work, not the french one (spanish is
   for the future). If I set french as admin language I see the translations, but
   not just putting the subdomain fr.sacconicase.com. I cant see why my code cant
   understand the locale language for french
 * I got some answers form the A.I. but from the theoretically point of view I shoulndt
   need any new code. The A.I: 
   Model 09:30This debug result is extremely valuable
   and tells us exactly where the problem lies.Let’s analyze the output:Domain Host:
   fr.sacconicase.com (Correct)WPLANG Constant: fr_FR (Your wp-config.php is working
   and the constant is defined!)get_locale() current: it_IT (WRONG. WordPress is
   ignoring the WPLANG constant and using Italian)Why does this happen?The most 
   likely cause on a modern WordPress site (version 4.0 or later) is that the language
   setting in the database (in the wp_options table, WPLANG option) is overriding
   the constant defined in wp-config.php.In simple terms: your database says the
   site language is Italian, and WordPress uses that, ignoring the config.The Ultimate
   SolutionWe need to tell WordPress to use the language defined in wp-config.php(
   or the domain), ignoring the one saved in the database.The right place to do 
   this is at the beginning of functions.php, so that it is executed before WordPress
   loads the options from the database.Action: Remove the debug code and replace
   it with this block at the top of your functions.php (after the <?php tag):codePHP//
   =============================================================================
   ======================================// FORCE LOCALE FROM CONFIG/DOMAIN (Ignore
   DB setting)// Fixes debugging issue where WPLANG was fr_FR but get_locale() remained
   it_IT// =====================================================================
   ===================add_filter( ‘locale’, ‘sacconicase_force_locale_from_config’,
   1 );
 * ..and so on with more code…
 * thank you
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fproblem-with-a-subdomain%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  Thread Starter [sacconi](https://wordpress.org/support/users/sacconi/)
 * (@sacconi)
 * [2 weeks ago](https://wordpress.org/support/topic/problem-with-a-subdomain/#post-18974806)
 * thank you. Just a curiosity, I noticed that chat gtp gives me code with much 
   more unusefull white lines, how can automatically reduce the lenght of the code,
   mantaining just the logical separations?

Viewing 1 replies (of 1 total)

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fproblem-with-a-subdomain%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [sacconi](https://wordpress.org/support/users/sacconi/)
 * Last activity: [2 weeks ago](https://wordpress.org/support/topic/problem-with-a-subdomain/#post-18974806)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
