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);

14 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.

  4. Mindaugas says:

    does it support ‘hidden’ class for styling currently active language? like .current_page_item in wp itselft to style selected page in navigation.

    here is the example what i’m trying to achieve:

    http://www.dixevil.com/limoluxx/

  5. Nasser says:

    Hi there,
    Thank you for such a wonderful plugin. I want to be able to auto create empty translation pages for each new post created in my website. which tables, other than the wp_icl_translations are affected?

  6. webdev says:

    How to find a list of available languages of current site and what language is the main one.
    p.s. Thanks for plugin.

  7. Ray says:

    Hi, to make our decision, our developer is asking: “Please ask your plugin author (of the plugin that creates multiple domains) how it differentiates between domains. How the plugin determines these domains is important in this scenario.”

    Could you please, let us know the variable to get the different domains?

  8. Vladimir says:

    How to get constant (ICL_LANGUAGE_CODE) in my plugin?
    echo ICL_LANGUAGE_CODE; not work and print only text “ICL_LANGUAGE_CODE”.
    Please help.

  9. Björn Ali says:

    To ease theme development for novice programmers, something like “icl_get_name_of_post( … )”, icl_get_permalink_of_post( … ) etc could be helpful.

  10. Murali says:

    amir , how to create a custom wordpress post creator in frontend.

    i can add a new post using , wp_insert_post().
    But wat value i need to pass for post_content and post_title or something else to create a post in a different language, say arabic..

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="">

Subscribe without commenting