Is ConvertPlus compatible with WPML? How to translate?

I have Google it, but I have not found an answer. Do you know how to translate an infobar created with this plugin?

Thanks :slight_smile:

Carlos

Hi there,

Thanks for writing in.

You’ll have to create two different popup for each language, then follow this https://www.convertplug.com/plus/docs/how-to-create-a-language-specific-popup-in-convertplus/. With that code, you can decide if it’s going to be displayed or not depending on the language. Example

function cp_callback_function( $display, $style_id ) {
     
        if( $style_id == 'cp_id_23423' && ICL_LANGUAGE_CODE == 'en') return true;
        if( $style_id == 'cp_id_23424' && ICL_LANGUAGE_CODE == 'fr') return true;

    return $display;

}
add_filter( 'cp_target_page_settings', 'cp_callback_function', 10, 2 );

So with cp_id_23423, it’s the info-bar that you created for English, so does cp_id_23424 for another language. Then the content of your info-bar should match the language it represents.

Thanks!

You mean there is NOT any way to do it WPML, so you are giving me the best workaround you know? :confused:

If your looking for an interface in the back-end, regretfully there’s none. You will nee to follow what has been suggested previously.

Thanks.

It works beautifully… Both infobar must be enabled to work, by the way :slight_smile:

Nooo. There is one more issue haha. I show the infobars only in two specific pages:

Unfortunately, after adding your code to functions.php, the infobars are shown in every page of the website.

Any idea about how solving that? :thinking:

Thank you one more time!!!

Carlos

Hi Carlos,

Feel free to add the page ID of Compra HeroMask and Smartphones compatibles on the logic filter. We can use is_page function.

Try something like this:

function cp_callback_function( $display, $style_id ) {
     
        if( $style_id == 'cp_id_23423' && is_page( 42 ) && ICL_LANGUAGE_CODE == 'en') return true;
        if( $style_id == 'cp_id_23424' && is_page( 42 ) &&ICL_LANGUAGE_CODE == 'fr') return true;

    return $display;

}
add_filter( 'cp_target_page_settings', 'cp_callback_function', 10, 2 );

Change 42 to your page ID. The code is now checking 3 things: correct converplus ID, page ID and then language before it shows the content.

Hope this helps.

This is weird. I’m not being able to make it work well. The previous code that was working but shown in all pages (instead of specific ones) was:

// To translate Convert Plus info bar 1
function cp_callback_function( $display, $style_id ) {
     
        if( $style_id == 'cp_id_7ad81' && ICL_LANGUAGE_CODE == 'en') return true;
        if( $style_id == 'cp_id_8d038' && ICL_LANGUAGE_CODE == 'es') return true;

    return $display;

}
add_filter( 'cp_target_page_settings', 'cp_callback_function', 10, 2 );

The modification to show it in only 2 specific pages (so 4 because of the translations):

// To translate Convert Plus info bar 1. Only shown on pages A and B.
function cp_callback_function( $display, $style_id ) {
     
        if( is_page( 2390 ) || is_page( 2528 ) && $style_id == 'cp_id_7ad81' && ICL_LANGUAGE_CODE == 'en') return true;
        if( is_page( 202 ) || is_page( 182 ) && $style_id == 'cp_id_8d038' && ICL_LANGUAGE_CODE == 'es') return true;

    return $display;

}
add_filter( 'cp_target_page_settings', 'cp_callback_function', 10, 2 );

Both info bar (original and translated into English) are live:

I have double check that style_id == 'cp_id_7ad81' is correct and post=2390 for the translated (English) version:

Can you see my mistake? Please help :confused:

Thank uuu

Carlos

Hi Carlos,

We should put the is_page function check into another parenthesis. This way, both of this will be checked first before appending the language and convertplus filter like this:

// To translate Convert Plus info bar 1. Only shown on pages A and B.
function cp_callback_function( $display, $style_id ) {
     
        if( (is_page( 2390 ) || is_page( 2528 )) && $style_id == 'cp_id_7ad81' && ICL_LANGUAGE_CODE == 'en')   $display = true;
        if( (is_page( 202 ) || is_page( 182 )) && $style_id == 'cp_id_8d038' && ICL_LANGUAGE_CODE == 'es') $display = true;

    return $display;

}
add_filter( 'cp_target_page_settings', 'cp_callback_function', 10, 2 );

I have tested that code and it is working. Important thing to note is on Convertplus setting > Repeat Control and Target Visitors. Make sure it is set correctly.

Yes! It’s working perfectly. Thanks so much for the code and explanations! :slight_smile:

Carlos

You’re most welcome!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.