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 trial

WordPress

Maja B.
Maja B.
12,984 Points

<title> displays both languages

Hi, Any idea how to make the site <title> display only in one language?

  • I have a WordPress site and I'm using qTranslate-X plugin for translation.
  • I have two languages (English and Deutsch).
  • I'm on the page titled Map (English) and Landkarte (Deutsch).
  • The general site title is Maja Blejec.

The title is written like this:

<title><?php wp_title( '|', true, 'right' ); ?></title>

and displays like this in the browser's tab:

MapLandkarte - Maja Blejec

So what shroud I do to make it display like this (if I'm on English site):

Map - Maja Blejec

and like this if I'm on Deutsch site:

Landkarte - Maja Blejec

1 Answer

Hi Maja,

I haven't tried this myself but could you use the following combined with an if statement?

get_bloginfo ('language');

-Rich

Maja B.
Maja B.
12,984 Points
get_bloginfo ('language');

gives EN or English language and DE for Deutsch language. But how does that affect the title tag in the head?

I don't understand ...

Hi Maja,

Sorry for the delay. I had misunderstood the question.

It's a slightly older post but does this help?

https://wordpress.org/support/topic/plugin-qtranslate-page-title

-Rich

Maja B.
Maja B.
12,984 Points

Thanks, Rich,

Following the link you have provided, I've tried this:

<?php $post_meta = get_post_meta($post->ID, 'meta_key', true) ?>
<title><?php echo qtrans_use($q_config['language'], $post_meta, true);  ?></title>
ยด```

but it does not work (the site is blocked completely and it does not load at all; seems like a major error).

One important thing is that I'm not using qTranslate but qTranslate-X.

Ah ok, not sure I'm going to be much help I'm afraid. As I say I haven't had to implement this myself so it's a little bit of guess work hence the link. Will come back if I find anything in the meantime.

-Rich

Maja B.
Maja B.
12,984 Points

Okay, thanks anyway.