Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: America/Los_Angeles (GMT-07:00)

This topic contains 7 replies, has 3 voices.

Last updated by Bobby 1 year, 4 months ago.

Assisted by: Bobby.

Author Posts
November 29, 2022 at 2:30 pm #12555449

elizabethU-2

We have a button in the footer template that looks like this:

<a href="/contact/"> <button class="stickycontactButton"> <svg style="width:25px; color:#fff;" xmlns="hidden link" viewBox="0 0 512 512"> <path d="M464 64C490.5 64 512 85.49 512 112C512 127.1 504.9 141.3 492.8 150.4L275.2 313.6C263.8 322.1 248.2 322.1 236.8 313.6L19.2 150.4C7.113 141.3 0 127.1 0 112C0 85.49 21.49 64 48 64H464zM217.6 339.2C240.4 356.3 271.6 356.3 294.4 339.2L512 176V384C512 419.3 483.3 448 448 448H64C28.65 448 0 419.3 0 384V176L217.6 339.2z"></path> </svg> </button> </a>

How we can we make it so the href changes on the other languages?

At the moment, it always directs them to the UK site.

Thanks

November 29, 2022 at 8:52 pm #12558131

Andreas

Hi,

before your ticket is assigned to one of my colleagues, please allow me to walk you through some initial debugging steps. This will help speed up the support process.

May I ask you to read this :

https://wpml.org/faq/how-to-translate-urls-shortcodes-and-html-attributes-using-the-advanced-translation-editor/

Regards,
Andreas

December 7, 2022 at 2:39 pm #12607997

elizabethU-2

Hey, how do I find the advanced editor for a HTML element that's present on every page? (it's included in the footer)

December 7, 2022 at 8:04 pm #12609715

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hi there,

Go to WPML->Settings-> verify that you have enabled the Advanced transation editor(ATE)

Then follow the steps from the documentation my colleague shared.

when you click on "+" and open the translation in the ATE you will see the option to search HTML elements at the top left.

Let me know your results, please.

December 8, 2022 at 12:12 pm #12614557

elizabethU-2

I translated a test page just to see if it detects the HTML element, but when searching, nothing comes up. The HTML element isn't included in the page builder, perhaps this is why? it's part of the footer.php template, which loads on every page.

Screenshot 2022-12-08 at 12.11.23.png
December 8, 2022 at 10:40 pm #12617663

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

I possibly misunderstood, but yes you are correct; If the HTML is within the footer's code and hardcoded it will not show in the WPML editor.

For hardcoded content, you will either need to create a custom logic filtering for the language OR wrap the HTML in a gettext call to translate using WPML String Translation.

See the following documentation for reference

https://wpml.org/documentation/support/translating-the-theme-you-created/

https://wpml.org/documentation/support/wpml-coding-api/

December 9, 2022 at 11:30 am #12620581

elizabethU-2

Thanks!

We now have this in our footer.php template:

<?php if ( $newlang = "es" ) {
$link = "hidden link";
}?>

<?php if ( $newlang = "pt-br" ) {
$link = "hidden link";
}?>

<?php if ( $newlang = "de" ) {
$link = "hidden link";
}?>

<?php if ( $newlang = "en" ) {
$link = "hidden link";
}?>

and this in our functions.php template:

function get_language_shortcode() {
$lang = apply_filters( 'wpml_current_language', null );
return ($lang);
}
add_shortcode( 'language', 'get_language_shortcode' );

$newlang = do_shortcode('[language]');

ISSUE: For some reason it always sets the link to being the last IF statement. In this instance, all languages are being set as the English link as it's the last IF statement. Any idea why?

December 9, 2022 at 8:05 pm #12623379

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Unfortunately, custom programming work is beyond the scope of our support.

I am not able to see something apparent at the moment, To possibly test the logic further, I'd recommend using an if-else statement rather than 2 ifs.

I would suggest you consider contacting one of our certified partners from this link:
http://wpml.org/documentation/support/wpml-contractors/

You will get the custom assistance you need to get on with your project.

Before doing so please have a look also here:
http://wpml.org/documentation/support/wpml-contractors/guidelines-for-people-looking-for-consulting-help/

The topic ‘[Closed] Dynamic Link’ is closed to new replies.