Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialfabrciojardimferreira
8,100 PointsWhy this _() function was used instead of just entering the string?
Taking this code as example:
function register_theme_menus() {
register_nav_menus(
array(
'primary-menu' => _('Primary Menu')
)
);
}
Why use _() instead of just entering the string? According to the Wordpress Codex all it do is take a string and return it back.
function _($string) {
return $string;
}
1 Answer
Malte Zwillus
9,448 PointsHey Fabrício,
this is for making strings translatable. Every string that is inside of a translation function ( e.g. __(), _x() ... ) can be translated through a translation file. You can find more information here: https://codex.wordpress.org/I18n_for_WordPress_Developers
Regards Malte
fabrciojardimferreira
8,100 Pointsfabrciojardimferreira
8,100 PointsThank you.