0

Sorry for this novice question. I'd like to know why WordPress themes add their theme names many occasions in PHP files (e.g. where 'twentynineteen' is repeated below, this is from functions.php in twentynineteen theme). Looks like themes can function fine without those names included, though.

register_nav_menus(
array(
'menu-1' => __( 'Primary', 'twentynineteen' ),
'footer' => __( 'Footer Menu', 'twentynineteen' ),
'social' => __( 'Social Links Menu', 'twentynineteen' ),
)
);

Is there any particular reason why theme names are included? Thank you in advance for your advice!

2

The name you see is the text domain of the theme. __('some text', 'text-domain') is a translation function, which makes it possible to translate the some text into different languages. There are also other translation functions that can be used in different situations. You can learn more about translations on the codex, I18n

P.s. if the text domain is left out, the function uses default WP text domain and tries to find translations from that. For example simple strings, like yes and no, usually gets translated from the default translations.

  • Haha, you were faster. I was about to push the submit button :p – Krzysiek Dróżdż Apr 20 at 8:18
  • 1
    Haha, I had the feeling that answering to this question would be a speed typing contest :D – Antti Koskinen Apr 20 at 8:23
  • Thank you both for getting back to me with a pointer. I'll read the resource. Thanks! – Joey Apr 20 at 8:26

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.