Reputation: 6370
I'm using Wordpress with a language switcher to switch between various languages. Within the templates I'm using this piece of code to switch hard coded text.
<?php if(ICL_LANGUAGE_CODE == 'en') { ?>
This is english
<?php } else { ?>
This is another language
<?php } ?>
I have a sidebar but it's created via various widgets so I can't put the same fix in place.
Using jquery, how can I target all the text within a specific div and replace it with something else?
If I put that jquery within the code above then that should work shouldn't it?
Upvotes: 4
Views: 1873
Reputation: 104775
jQuery/JS is Client, PHP is server, so that being said, there is one chance to inject PHP into JavaScript, and that is at the run-time of the page. You can probably do something like:
$(document).ready(function() {
var language = '<?php echo ICL_LANGUAGE_CODE?>';
if (language == "EN") {
$("#IDOFDIV").html("NEW HTML HERE");
}
});
Upvotes: 2