Add Multilingual to your wordpress site using(wpml)
1-add the following line to:
functions.php
1 2 |
//Custom Script By Greenbackend.com include_once 'greenbackend/custom.php'; |
or download Functionality plugin to separate what you might normally place in a theme’s functions.php file, and put it in a plugin instead. It works the same way as a theme functions.php file, but is separate from the theme and so not affected by theme upgrades, or tied to the theme so you loose all of your functions if you choose to switch themes.
https://wordpress.org/plugins/functionality/
1 2 3 4 5 |
//Custom Script By Greenbackend.com include_once plugin_dir_path( __FILE__ ) .'../../themes/yourtheme/greenbackend/custom.php'; //*OR*// //include_once ABSPATH .'wp-content/themes/yourtheme/greenbackend/custom.php'; |
2-create custom.php in greenbackend theme folder
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
<?php //echo "greenbackend.com"; add_action('wp_enqueue_scripts','LoadCustomScript'); function LoadCustomScript(){ if(ICL_LANGUAGE_CODE == 'en'){ wp_enqueue_script("EnglishGBE","https://example.com/wp-content/themes/yourtheme/greenbackend/js/en.js"); wp_enqueue_style("EnglishCSSGBE","https://example.com/wp-content/themes/yourtheme/greenbackend/css/en.css"); } if(ICL_LANGUAGE_CODE == 'ar'){ wp_enqueue_script("ArabicGBE","https://example.com/wp-content/themes/yourtheme/greenbackend/js/ar.js"); wp_enqueue_style("ArabicCSSGBE","https://example.com/wp-content/themes/yourtheme/greenbackend/css/ar.css"); } if(ICL_LANGUAGE_CODE == 'he'){ wp_enqueue_script("HebrewGBE","https://example.com/wp-content/themes/yourtheme/greenbackend/js/he.js"); wp_enqueue_style("HebrewCSSGBE","https://example.com/wp-content/themes/yourtheme/greenbackend/css/he.css"); } } ?> |
3- create two folders for js and css in greenbackend folder and add the css files and javascript files for each language
css folder
/css
ar.css
en.css
he.css
/js
ar.js
en.js
he.js
download sample from themes-greenbackend