admin管理员组

文章数量:1430970

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!

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!

Share Improve this question asked Apr 20, 2019 at 8:06 JoeyJoey 235 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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.

本文标签: