Home » Documentation » Developers information » WPML coding API

WPML coding API

WPML offers functions that can be used in your WordPress theme to provide correct support for multilingual themes.

Function Purpose Notes
do_action(‘icl_language_selector’) Insert the drop down language selector. Described in the language setup section of the getting started guide.
do_action(‘icl_navigation_menu’) Insert the top navigation menu. Described in the navitaion section of the getting started guide.
do_action(‘icl_navigation_breadcrumb’) Insert the breadcrumbs trail.
do_action(‘icl_navigation_sidebar’) Insert the sidebar navigation.
icl_get_home_url() Link to the home page in the active language. Described in the home page link section of the getting started guide.
icl_get_languages(’skip_missing=N’) Used for building custom language selectors. Described in the custom language switcher section of the getting started guide.
icl_link_to_element(ID, type, text, arguments, anchor) Used for creating language dependent links in themes. Described in the hard coded links section of the getting started guide.
icl_object_id(ID, type, return_original_if_missing, language_code) Used for calculating the IDs of objects (usually categories) in the current language. Described in the language dependent IDs section of the getting started guide.

Language constants

WPML defines the following constants which can be used in the theme:

Constant Description Example
ICL_LANGUAGE_CODE Code for the current language fr
ICL_LANGUAGE_NAME Name of current language, in the current language Français
ICL_LANGUAGE_NAME_EN Name of the current language name in English French

Disabling WPML’s CSS and JS files

WPML comes with its own CSS and JS files that style its navigation and drop-down language switcher.

If you don’t need them in your theme, you can tell WPML not to load these files. Do to that, define the following constants in your theme:

Constant The file it disables
ICL_DONT_LOAD_NAVIGATION_CSS Navigation stylesheets – cms-navigation-base.css and cms-navigation.css
ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS Drop-down language selector stylesheet – language-selector.css
ICL_DONT_LOAD_LANGUAGES_JS Drop-down language selector Javascript – sitepress.js

To set these constants, define them in the theme’s functions.php file. For example:

define('ICL_DONT_LOAD_NAVIGATION_CSS', true);

5 Responses to “WPML coding API”

  1. Paresh says:

    Hi….
    Its really a nice plugin given by WPML.org,
    I go thoroly….And implement it,

    But now one and only problem is I cant found .po and .mo files for each languages I Used.

    So please give me Hint, from where can I get those files.

  2. Serguey SEO says:

    Hi
    Thanks for excellent plugin but I’ve got problems using it.

    I’ve try to check current language but

    gives me only ‘en’ value instead of ‘ru’ when I’m on http://www.domain.com/ru/whatever.html

    What have I do wrong? How to check current language better?

    Regards Serguey

    • amir says:

      This sort of thing is exactly what the forum is used for. Please post it there with details that will allow us to see the problem in your site AND recreate it locally.

  3. Martin says:

    Hi … and thanks (from the bottom of my developer heart) for this great plugin!
    WMPL is now an integrated part of our WordPress framework. It is the best tool we found to produce stable WP themes for our canadian bilingual clients/users.

    About those functions, is there any way to re-use them within TinyMCE WYSIWYG generated contents (the_content) like somekind of a “shortcode” brackets to generate sticky links ?
    … Or maybe this technical question is a case for the forum.

    Thank’s anyway & Keep on the good work.

Leave a Reply

Please leave here comments about this page only.
For technical support and feature suggestions, head to our forum. We are waiting there!

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">