Plugin Author
Chouby
(@chouby)
Thread Starter
birhon
(@birhon)
This is described in the documentation:
http://polylang.wordpress.com/documentation/documentation-for-developers/tips-and-tricks/how-to-display-the-default-language-post-if-the-translation-does-not-exists/
Thank you very much Chouby,
unfortunately, WordPress.com is not available in China. I can’t see it. If you have a minute, can you please copy-paste the content here or to the plugin support page at wordpress.org. thank you!
Plugin Author
Chouby
(@chouby)
Here is the copy paste.
Example of modified loop to get this result (supposing the default language is English):
<?php // force querying the English posts
global $wp_query;
query_posts(array_merge($wp_query->query, array('post_type' => 'post', 'lang' => 'en'))); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php global $post;
// get translated post (in current language) if exists
if($post_id = pll_get_post($post->ID, pll_current_language())) {
$post = get_post($post_id);
setup_postdata($post);
}?>
//... do what ever you want in your loop ...
Note that you must have all posts available in the default language for this to work correctly. See also Showing default language post if no translation is available on the forum for an application to the Twenty Eleven theme.