What is better for wordpress performace?

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:

Read More
<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.

Related posts

Leave a Reply

1 comment

  1. _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.