WPML is a plugin which has the ability to turn your WordPress site into complete multilingual content management systems. Unfortunately, until now I meant, at least until the time before I found this following solution, WPML only supports for the translation of the WordPress original content, such as: posts, pages, categories, tags, and menus (since WordPress version 3.0). I can understand about this, since there are so many possibilities about the content you may have in Pods CMS! That is why WPML has not supported for Pods CMS plugin, yet, whereas this feature I have been looking for that could be implemented in WPML too. I have been waiting for such long time, and… today… God bless the day I found this following solution, indeed! Although the following modification I made sounds like a little tricky or hackish into the WPML’s code, but it works very fine at mine. So, if you are using Pods CMS and WPML for your WordPress site, and you want to add your own translation link that came from your own content in Pods CMS into the language switcher that belongs to WPML, then you came to the right place, because this modification is only for you!
Another information that you need to know is my site uses two languages: English and Indonesian (default language = Indonesian).
So, this is what I did on my WPML 1.8.0:
-
Open /wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php file, and I find this code:
3399 3400 3401
}elseif(is_search()){ $url_glue = strpos($this->language_url($lang['code']),'?')===false ? '?' : '&'; $lang['translated_url'] = $this->language_url($lang['code']) . $url_glue . 's=' . htmlspecialchars($_GET['s']);
then after the last line of that code, I added this following code:
3403 3404 3405 3406 3407 3408 3409
}elseif(is_pod_page() ) { // Modified by Masino Sinaga, July 14, 2010 global $slug_en, $slug_id; if ($lang['code']=='en') { $lang['translated_url'] = $slug_en; } else { $lang['translated_url'] = $slug_id; } // Modified by Masino Sinaga, July 14, 2010
-
Open functions.php file that located in my theme that I currently using, and then I added this following code at the top/declaration section of the file:
global $slug_id, $slug_en;
those variables important in order to tell WPML that in my Pods template, I use them to get the link from my Pods’ content.
-
In my Pods’ template that I created inside my theme directory, I added this following code:
global $slug_id, $slug_en; $slug_id = site_url().'/propinsi/'.$Record->get_field('slug_id'); $slug_en = site_url().'/en/province/'.$Record->get_field('slug_en');
This is only one of the examples how I assign those two variables that mentioned above, so this Pods’ template will hold the values, and then the functions.php file will act as the bridge between Pods and WPML. In other words, the value of variables will be known by WPML that derived from the Pods.
You can see the demo from this following link:
One of the Indonesia Regions. As you can see now, the language switcher (at the right sidebar, also at the bottom of the site) automatically adds the links that came from Pods CMS, either for English or Indonesian.
You will see that those links suddenly just like the links that came from Posts or Pages in WordPress, but they are not. They came from my Pods content, everyone!
Isn’t that great? Oh, how much I love this!

Recent Comments