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'm using allot of custom queries, and qtranslate. Qtranslate works with everything that has home url in it. But for posts /thumb permalinks if I change language to Russian for example links remain default language specific.

So if I'm browsing /ru/ links on that page lack /ru/ so I get redirected back to default language. Does anyone know simple solution?

I've digged extensively and found this: qtrans_convertURL( 'http://www.mysite.com/post-name/' ); I could use this and put all my permalinks within this function. But there should be a simpler solution, right?

share|improve this question
If there's a public API function from the plugin, why not use it? – kaiser Sep 15 '12 at 11:01
@kaiser I was thinking this would be automatic. In header I've get_permalink for navigation and it works fine url gets appended with correct/current lang. But inside loop where I've the_permalink it doesn't work. I will substitute all the_permalinks with get_ version and see if that works. – Sandro Dzneladze Sep 15 '12 at 11:21
@SandroDzneladze it should work with both functions, qtrans_convertURL() is used as callback for post_link and the_permalink filters. – Mamaduka Sep 15 '12 at 11:54
@Mamaduka on further investigation I noticed that links don't work only for custom post types. Any thoughts why? – Sandro Dzneladze Sep 15 '12 at 12:49

I figured it out.

For the reference problem was links in custom post types. As it appears Qtranslate in its current iteration doesn't support custom post types. And the_permalink or get_permalink will not change to current lang as you switch them.

Solution was very simple.

Just include this in functions.php file of your theme.

add_filter('post_type_link',     'qtrans_convertURL');


share|improve this answer
 //this code solves most qtranslate issues
//add (/ru) to custom menu links created in menu section
function qtrans_menuitem( $menu_item ) {
if ($menu_item->type == 'custom' && stripos($menu_item->url, get_site_url()) !== false){
    $menu_item->url = qtrans_convertURL($menu_item->url);
return $menu_item;
add_filter('wp_setup_nav_menu_item', 'qtrans_menuitem', 0);

//add (/ru) to get_permalink($custom_post)
add_filter('post_type_link', 'qtrans_convertURL');
share|improve this answer
Please explain why this answer is helpful. Just code isn't. – kaiser Feb 3 '14 at 22:16

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.