Overview
Drop-in multilingual subsystem for Terra WordPress sites. Lives in its own repo β terra-hq/wp-multilang β and is cloned into functions/framework/ so the Terra Framework auto-loads it. Adds URL prefix routing (/en/, /es/, /eu/), per-field ACF translations, per-language SEO, and a per-language sitemap behind a thin layer of terra_*() template helpers.
Easy-going setup
Section titled βEasy-going setupβIn a hurry? Hereβs the bare minimum β no thinking required.
- Clone php-starter-core. Inside
functions/, rungit clone git@github.com:terra-hq/php-starter-core.git framework(the trailingframeworkrenames the cloned folder). - Clone wp-multilang. Inside
functions/framework/, rungit clone git@github.com:terra-hq/wp-multilang.git. The Terra Framework auto-loads it. - Drop in the config. Create
functions/project/config/multilang_config.phpwith at least two languages and adefault. - Flip the switch. wp-admin β Terra β System β Multilang β Enable.
- One line in
header.php. Replace<html lang="en">with<html <?php language_attributes(); ?>>. - Drop the switcher.
<?php terra_multilang_switcher(); ?>anywhere in your templates β header, footer, sidebar, wherever fits. - Save permalinks. Settings β Permalinks β Save Changes.
Thatβs it. Anything you donβt translate falls back to the native field, so the site keeps working at your own pace.
Setup (detailed)
Section titled βSetup (detailed)β1. Clone php-starter-core into functions/
Section titled β1. Clone php-starter-core into functions/βcd functionsgit clone git@github.com:terra-hq/php-starter-core.git frameworkThe trailing framework renames the cloned folder, so the framework lands at functions/framework/ (the path the rest of the project expects). Repo: terra-hq/php-starter-core.
2. Clone wp-multilang into functions/framework/
Section titled β2. Clone wp-multilang into functions/framework/βcd functions/frameworkgit clone git@github.com:terra-hq/wp-multilang.gitThe Terra Framework loads functions/framework/wp-multilang/load.php automatically β no extra require needed in your theme.
3. Create functions/project/config/multilang_config.php
Section titled β3. Create functions/project/config/multilang_config.phpβ<?phpreturn array( 'languages' => array( 'en' => 'πΊπΈ English', // first entry = primary language 'es' => 'πͺπΈ EspaΓ±ol', // 'eu' => 'π΄ Euskera', ), 'default' => 'en', // fallback when the URL has no prefix);- Key: language code used in URLs (
/es/), ACF sub-fields, and the date map. - Value: admin-visible label + switcher label.
4. Enable Multilang from the admin
Section titled β4. Enable Multilang from the adminβwp-admin β Terra β System β Multilang tab β check Enable Multilang β Save.
5. Update header.php
Section titled β5. Update header.phpβ<html lang="en" dir="ltr"><html <?php language_attributes(); ?>>6. Insert the language switcher
Section titled β6. Insert the language switcherβIn any template (typically the footer or header):
<?php terra_multilang_switcher(); ?>Auto-hides when there are fewer than 2 languages or when Multilang is OFF.
7. Flush rewrite rules
Section titled β7. Flush rewrite rulesβSettings β Permalinks β Save Changes (no need to change anything, just hit the button). This registers the per-language sitemap rewrite rules.
Knowledge Check
Test your understanding of this section
Loading questions...