Make a custom theme translate-ready

To do it properly, you need to generate a valid .mo file and load the text domain in your theme functions.php: function wpse222346_localize_theme() { load_theme_textdomain( ‘your_theme_domain’, get_template_directory() . ‘/languages’ ); } add_action( ‘after_setup_theme’, ‘wpse222346_localize_theme’ ); You can check the WordPress Codex for more info on the load_theme_textdomain function: https://codex.wordpress.org/Function_Reference/load_theme_textdomain Then you would call the translatable … Read more

How to develop a multilingual theme?

Daniel’s answer was very similar, but applied to plugins rather than themes. For that reason I’ll explain how I specifically did it for themes for anyone else who comes across this problem. Create a folder in the root of your theme called “languages” Go to https://wpcentral.io/internationalization/, search for your language and copy the “WordPress Locale” … Read more

Multisite – how to remove the root ‘/’ site?

I use on the root site a small theme for redirect to the languages. A very small theme for locate the language of the users and redirect to the blog of this language. <?php // Browsersprache ermitteln function lang_get_from_browser($allowed_languages, $default_language, $lang_variable = NULL, $strict_mode = TRUE) { // $_SERVER[‘HTTP_ACCEPT_LANGUAGE’] verwenden, wenn keine Sprachvariable mitgegeben wurde … Read more

Add code into on a per page/post basis

As you said per page/post basis, this would work for each post add_action(‘wp_head’, ‘add_link_in_head’); function add_link_in_head() { global $post; if(!empty($post)) { $alternate = get_post_meta($post->ID, ‘alternate’, true); $hreflang = get_post_meta($post->ID, ‘hreflang’, true); if(!empty($alternate) && !empty($hreflang)) { ?> <link rel=”alternate” href=”https://wordpress.stackexchange.com/questions/110260/<?php echo $alternate; ?>” hreflang=”<?php echo $hreflang; ?>” /> <?php } } } If there is no … Read more

WordPress | Sub-domain switching

You can Use qTranslate, this WordPress plugin let you have an easy to use interface for managing a fully multilingual web site. One-Click-Switching between the languages – Change the language as easy as switching Choose one of 3 Modes to make your URLs pretty and SEO-friendly. – The everywhere compatible ?lang=en, simple and beautiful /en/foo/ … Read more

Set language per post

I couldn’t find an answer so I ended up providing the solution. It wasn’t simple given that I am not an expert with wordpress nor with php but WordPress documentation is great so here is the solution: // Set the post language when loading up the page based on the store meta function ppl_set_post_language() { … Read more