WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing a website using the WPML plugin. And I would like to know which is the better option, or even the correct way to change classes or IDs between the languages.

Sample code:

<ul id="<?php _e('menu-topo'); ?>">

<ul id="<?php if ($lang = 'en') { echo "menu-topo-en"; } else { echo "menu-topo"; } ?>

I'm not sure that the _e function is supposed to be used this way so if someone could clarify this for me it would help me a lot, thanks.

share|improve this question
up vote 4 down vote accepted

_e() will translate the text passed as a argument to the language your site is currently set up to use (if the translation exists).

Anyway, don't do that. Use it for text visible on the website, not for IDs/classes etc. To create context based css rules, simply add the WPML language ID as a body class:

add_filter('body_class', 'wpml_body_class');
function wpml_body_class($classes){
  return array_push($classes, ICL_LANGUAGE_CODE);

then style the elements you need to using something like:

.en .menu-top{

It's faster, and you keep your code easy to maintain.

share|improve this answer
Amazing solution my friend, thank you! – Vitor Argos Apr 15 '11 at 20:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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