0

I'm creating my website with "elementor plugin". So I used to customize the default WordPress search result page since I couldn't access it with elementor.

Anyway, I tried to display my custom elementor footer using a short code:

<?php echo do_shortcode("[INSERT_ELEMENTOR id='319']"); ?>

The code above displays my footer in Arabic version.

<?php echo do_shortcode("[INSERT_ELEMENTOR id='3183"]'); ?>

And this one above is for English version.

How can I switch to any custom footer I want according to site language?

0

That's probably basic PHP. As all that's needed would be some kind of map/array and then switch use the id according to what get_locale() returns.

<?php

// Provide a map if locales and shortcode IDs.
$custom_footer = [
  'ar'    => '319',
  'en_US' => '3181',
  // ... and so on
];

// Get the current language.
$current_language = get_locale();

// Get the right shortcode ID.
$shortcode_id = $custom_footer[$current_language];

?>

<?php echo "Just for debugging, the current language is: " . $current_language; ?>

<?php echo do_shortcode("[INSERT_ELEMENTOR id='" . $shortcode_id . "']"); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.