Multilingual CMS plugin and GetRecentComments plugin for WordPress

In my WordPress installation I have the Multilingual WordPress by WPML plugin and the GetRecentComments plugin which for my pity are not working right together. The comments plugin shows entries in both languages. So to overcome this, because I want exactly these plugins, I had to modify the get recent comments. I will show you how I did it. But however you can set any other logic there – I have just two languages, so I did it the simplest working way for me. Here it is.

After line 1133 in get-recent-comments.php modify the code as following:

$lang = 'en';
if(strstr($_SERVER['REQUEST_URI'], '/bg/'))
 $lang = 'bg';

while ($comments_number < $requested_number_of_comments)
 $query = "SELECT * from $wpdb->comments JOIN {$wpdb->prefix}icl_translations t ON ({$wpdb->comments}.comment_ID = t.element_id AND t.element_type='comment' AND t.language_code = '$lang') WHERE comment_approved= '1' AND " .
 $sql_comment_type .
 $sql_exclude_owner .
 $sql_ignore_ip .
 "ORDER BY comment_date DESC LIMIT " . ($batch_number*$batch_size) . ",$batch_size";
 // echo "$query<br><br>";
 $comments = $wpdb->get_results($query);

You have to get the language first, I am using the folder structure, and then the modification is in the query.

This post is also available in: Bulgarian

  1. Apple’s reasoning in the brief rests on three pillars. First, that forcing Apple to write code that weakens its devices and the security of its customers constitutes a violation of free speech as protected by the Constitution.

  2. It’s a Very informative article, all the information are given very clearly.

  3. This is my first time to your website, I send you the very distinctive, deserve me to treasure.

  4. Your article I learned a lot of things, thank you.

  1. No trackbacks yet.