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 need some help on how to correctly format this code snippet for translation:

<?php next_post_link( '%link', __( '<span class="meta-nav">←</span> Nästa nyhet') ); ?>

I've used this method in my theme before:

_e( 'Nästa nyhet', 'mytheme');

But I don't know how to correctly type the _e translation method in my link output. I want to translate "Nästa nyhet".


share|improve this question
Remember, _e() will echo a translated string and __() will return a translated string. – EAMann Oct 10 '12 at 17:04
Hmm, I'm sorry I don't get it. I'm a designer guy just dabbling with wordpress themes and some minimal PHP. What's the difference in regard to translating wordpress strings? I've been using _e() throughout my theme and it has worked great so far. When should I use what? – Johan Dahl Oct 10 '12 at 17:28
Use _e() when you want to echo the content to the screen. Use __() when you want to return the translated string within a function for later manipulation. – EAMann Oct 10 '12 at 17:50
Sooo...If I wanted to translate the url slug of some taxonomy in my functions file, I would do that using __()? And for just a headline outputted on my page, _e() is correct? – Johan Dahl Oct 10 '12 at 17:59
Yes. Take a look at the Codex article for internationalization for more details ... – EAMann Oct 10 '12 at 18:24
up vote 2 down vote accepted

Don't wrap the entire section in __(), just wrap the part you need to translate:

<?php next_post_link( '%link', '<span class="meta-nav">←</span> ' . __( 'Nästa nyhet', 'mytheme' ) ); ?>
share|improve this answer
Thank you! That worked! I'll keep your advice in mind :) – Johan Dahl Oct 10 '12 at 17:29

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.