This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 2 replies, has 2 voices.

Last updated by andreasP-43 1 year ago.

Assigned support staff: Shekhar Bhandari.

Author Posts
May 13, 2019 at 8:36 pm #3801493



I have created a custom view (with Toolset) in order to display some post.

I also use the following shortcode in order to print post language text.

function current_language( $atts ) {
    // Attributes
    $atts = shortcode_atts(
            'id' => '',
            'part' => '',
    $language = wpml_get_language_information($atts['id']);
    return $language[$atts['part']];
add_shortcode( 'current_language', 'current_language' );

How can I extent the function in order to print language flag icon instead of text?

Thank you!

May 14, 2019 at 6:37 am #3803977

Shekhar Bhandari

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Welcome to WPML support. I'd be assisting you further on this issue.

You are using the wpml_get_language_information function which is the same as using the hook wpml_post_language_details

The language information that these hook returns include:
- the post language 2-letter code,
- the post locale,
- the language text direction (True for RTL, False for LTR),
- the post language translated name and native name and
- whether the current language is different from the post language (True/False)

The following hooks return active languages from the side with language codes and flags

You will need to create a function using these two hooks and return the flags.

Let me know if this helps.


May 17, 2019 at 8:26 am #3832279


My issue is resolved now. Thank you!