aatanasov
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Language Switcher in WordPressYou won’t need to connect the pages.
If you add a page with a name
home
to each language. All languages will use the same name, andif ( is_page( 'home' ) )
will work for all subsites.In that case, you won’t need to worry about the site’s language and URL (ru, etc.).
Please feel free to create a test WordPress multisite instance and experiment with the code you shared.
Forum: Fixing WordPress
In reply to: Language Switcher in WordPressRegarding the CSS/JS optimization issue: I’m not sure how exactly the optimization script works, but it can be prepared to optimize the pages based on page names.
In our case, the name of a page will be the same for each language (if added correctly), and the CSS/JS code should be loaded correctly (based on page names, not on full URLs).
Forum: Fixing WordPress
In reply to: Language Switcher in WordPressThe simplest option is when you list the languages (the language switcher options), you can append the name of the particular reviewed page to each language URL.
For example, we have these sites added to the network:
– https://example.com/ (English)
– https://example.com/es/ (Spanish)When someone opens an URL like https://example.com/about/, the switcher will use these URLs:
– English: https://example.com/about/
– Spanish: https://example.com/es/about/You can get the page name using the get_post_field function. For example:
get_post_field( 'name' );
.When the Spanish version is clicked, the user will be redirected to the Spanish version of the page. However, in that case, you’ll need to ensure that the page is added to each language. Otherwise, the 404 error page will appear.
There are some advanced options, but the proposed solution might work for you.
- This reply was modified 2 years, 6 months ago by aatanasov.
Forum: Fixing WordPress
In reply to: Language Switcher in WordPressHi Arthur,
WordPress doesn’t have a language switcher out of the box.
The multilingual feature is a part of the long-term roadmap of the new WordPress site editor outlined on https://www.ads-software.com/about/roadmap/
Since a plugin such as PolyLang isn’t an option, you can look into the WordPress Multisite feature. Basically, you can create a subsite for each language and manage the content separately.
Your PO/MO files should be available in the /wp-content/languages/ folder. When you select a language for a subsite, the files should be loaded automatically if the theme supports internationalization.
However, the language switcher will need to be integrated into your theme, which will require coding skills. Alternatively, you can review this plugin https://www.ads-software.com/plugins/multisite-language-switcher/ — it works with subsites.