[Plugin: Polylang] How to get post language during a mixed language Loop?
-
Hi Chouby,
It’s been a while but the issue has come back since
get_option('rss_language')was dropped in WP 3.4 (as expected). We have talked about it before on http://ww.wp.xz.cn/support/topic/plugin-polylang-static-home-page-404-issue?replies=54 but to recap, the problem is this:I’ve got a Google News XML feed (plugin) that lists all the latest post URLs (of the last 48 hours) in all languages. This is how Google prefers it, all languages in the same XML. But… each item/post must have the proper language tag assigned. Like this example:
<url> <loc>http://4visions.nl/2012/06/wordpress-platform-upgrade/</loc> <news:news> <news:publication> <news:name>4Visions</news:name> <news:language>en</news:language> </news:publication> <news:publication_date>2012-06-19T14:08:49+00:00</news:publication_date> <news:title>WordPress platform upgrade</news:title> <news:keywords>upgrade</news:keywords> <news:genres>Blog</news:genres> </news:news> </url> <url> <loc>http://4visions.nl/2012/06/upgrade-van-het-wordpress-platform/</loc> <news:news> <news:publication> <news:name>4Visions</news:name> <news:language>nl</news:language> </news:publication> <news:publication_date>2012-06-19T13:28:03+00:00</news:publication_date> <news:title>Upgrade van het WordPress platform</news:title> <news:keywords>Platform</news:keywords> <news:genres>Blog</news:genres> </news:news> </url> ...(notice the <news:language> tags)
So what I want is to get each posts language while going though The Loop. But whatever I try, I get the sites default language… Before in WP 3.3, I used
get_option('rss_language');which after a mod to Polylang on your part, worked perfectly. Now, for WP 3.4 where get_option(‘rss_language’) was dropped, I switched toreset(explode('-', get_bloginfo_rss('language')))but this value does not get changed during the Loop so only the default language is used in each language tag.I tried using
$polylang->get_post_language($post->ID)andget_the_terms($post->ID, 'language' )but those do not return anything.Is there any way (don’t mind adding a function for this, as long as it is possible) to get to a posts language without falling back on the global language during the Loop?
Thanks for your thoughts!
.Allard
The topic ‘[Plugin: Polylang] How to get post language during a mixed language Loop?’ is closed to new replies.