WordPress and qTranslate: translate menu items

If you have installed qTranslate for the first time in your blog, and you already had a navigation menu with some items, what is the best way to translate those navigation items?

I have found that the easiest way to achieve this is by using some SQL (or phpMyAdmin) to directly modify the values in the database.

Follow this steps:

– open your phpMyAdmin to manage the DB
– go to table wp_posts and click on the Search link
– make a backup :), then
– filter by post_type=nav_menu_item
– look for the non translated records (field post_title)
– modify the field, ie: ‘My menu label in italian’ becomes ‘My menu label in italianMy menu label in english

An example:
qtranslate menu items translation

Display qTranslate flags (language switcher) in your wordpress theme [SOLVED]

How to display a language switcher in your wordpress theme? Easy!

Edit your template file, for instance, header.php and include the following lines:

<!-- alternador de idiomas qTranslate --->
<?php if (function_exists('qtrans_generateLanguageSelectCode')) { echo qtrans_generateLanguageSelectCode('image'); } ?>

qTranslate and wordpress 3.7 [SOLVED]

If you want to migrate to new wordpress version (3.7) and are using qTranslate, make the following change to /wp-content/plugins/qtranslate/qtranslate.php before updating wordpress to the newer version!!

QT_SUPPORTED_WP_VERSION must be 3.7 as in:

define('QT_SUPPORTED_WP_VERSION', '3.7');

If you do it BEFORE UPDATING, your life will be easier. If you don’t, the plugin will auto-disable and you’ll face some issues…

WordPress: smooth slider and qTranslate [solved]

WordPress extension Smooth Slider is a great choice for implementing a post+thumbnail slider in your site.

However, by default it does not work with qTranslate.

If you want smooth slider to show the post in several languages (the ones you defined used qTranslate), edit /wp-content/plugins/smooth-slider/slider_versions/j.php.

Change from (around line 50):

$rs_post = $wpdb->get_results("SELECT * FROM $posts_table WHERE ID = $id", OBJECT);
$data = $rs_post[0];
$post_title = stripslashes($data->post_title);
$post_title = str_replace('"', '', $post_title);
$slider_content = $data->post_content;

To:

$rs_post = $wpdb->get_results("SELECT * FROM $posts_table WHERE ID = $id", OBJECT);
$data = $rs_post[0];
 
// make multilang titles with qtranslate
$post_title = stripslashes(qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($data->post_title));
$post_title = str_replace('"', '', $post_title);
// make multilang excerpts(contents) with qtranslate
$slider_content = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($data->post_content);

And if your permalinks are not working, use the qtrans_convertURL($permalink) to convert permalinks too.

WordPress: WP Category post list and qTranslate issues [SOLVED]

WP Category post list and qTranslate are two of the plugins I usually use when developing websites with WordPress.

When using both of them together, all different post titles are concatenated to one big title (which contains the titles in all languages concatenated).

To fix this, simply edit wp-content/plugins/wp-category-posts-list/includes/wp_cpl_output_get.php and change from:

/** Add up the actual permalink and post title */
                $post_output .= '<a href="' . get_permalink($post->ID) . '" title="' . __('Permalink to: ', 'wp-cat-list-itg') . $post->post_title . '" target="' . ((false == $op['open_in'])? '_blank' : '_self') . '">' . $post->post_title . '</a>';

to

if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
				$post->post_title = esc_html(qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($post->post_title));
			}
 
                /** Add up the actual permalink and post title */
                $post_output .= '<a href="' . get_permalink($post->ID) . '" title="' . __('Permalink to: ', 'wp-cat-list-itg') . $post->post_title . '" target="' . ((false == $op['open_in'])? '_blank' : '_self') . '">' . $post->post_title . '</a>';

And your titles will be displayed correctly in each language 🙂