Quantcast
Channel: polylang – WordPress.org Forums
Viewing all articles
Browse latest Browse all 11471

karpediem on "[Plugin: Polylang] Afficher les posts dans la langue par défaut si pas de traduction"

$
0
0

I'm sorry but my english is very bad and author of plugin is french :o)

I am going to try but I'm afraid about the result and the answer...

My site was created at first in English : language by default, and now, I attack the translations.
My home page is a static page.
This page contains 5 posts which 1 only one contains of the text. To identify these 5 posts, I put them in a category (but maybe there is another more effective solution)
So, I thought that if I translated only the post text and if for the 4 others I display the post in the language by default, that should be good.
I thus translated only the post text.
Here is what I put in my template of home by inspiring me of doc of polylang

<?php
$args = array ( 'category_name' => 'accueil-en' );
// The Query
$the_query = new WP_Query( $args );
// The Loop
	while ( $the_query->have_posts() ) : $the_query->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);
}?>
<div id="home-<?php the_ID(); ?>" class="<?php $classe = get_post_custom_values('home_pos') ; echo $classe[0] ; ?>">
<?php
	the_title('<h1>','</h1>');
	the_content(); ?>
</div>
<?php endwhile;

// Reset Post Data
wp_reset_postdata();
?>

The url of my home page changes well when I choose an other language, but I always have the English version, as if I had made nothing.

I did not attack the translation of yet title. I think that I am going to have to make it by using pll_e with pll_register_string is good it ?

If somebody has an idea, I am a buyer; o)
Thank you


Viewing all articles
Browse latest Browse all 11471

Trending Articles