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?
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?
Share Improve this question edited Apr 12, 2019 at 11:42 norman.lol 3,2413 gold badges30 silver badges35 bronze badges asked Apr 12, 2019 at 9:39 AtefAtef 1232 bronze badges1 Answer
Reset to default 0That'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 . "']"); ?>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745596867a4635166.html
评论列表(0条)