• Bonjour,
    Mon site a été au départ créé en anglais (langue par défaut) et maintenant, je m’attaque aux traductions.
    Ma home page est une page static. Cette page contient 5 posts dont 1 seul contient du texte. Pour identifier ces 5 posts, je les ai mis dans une catégorie (mais peut-être y a-t-il une autre solution plus efficace)
    Du coup, j’ai pensé que si je traduisais uniquement le post texte et que pour les 4 autres j’affichais le post dans la langue par défaut, ?a devrait le faire.
    J’ai donc traduit le post texte et les autres pas.
    Voila ce que j’ai mis dans mon template de home en m’inspirant de la doc de 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();

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your posted code may now have been permanently damaged/corrupted by the forum’s parser.]

    Ce qui se passe, c’est que quelle que soit la langue choisie, j’ai toujours la version anglaise, comme si je n’avais rien fait. En revanche, l’url de ma page change bien…

    Je ne me suis pas encore attaqué à la traduction des titre. Je pense que je vais devoir le faire en utilisant pll_e avec pll_register_string c’est bien cela ?

    Si quelqu’un a une idée, je suis preneuse ;o)
    Merci

    https://www.ads-software.com/extend/plugins/polylang/

Viewing 5 replies - 1 through 5 (of 5 total)
  • These are English language forums. Please use English.

    Thread Starter karpediem

    (@karpediem)

    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

    You could always try posting on https://wordpress-fr.net/support/

    Plugin Author Chouby

    (@chouby)

    I visit the french support forum from time to time. The answer may not come as quick as here, but you won’t have to worry about your English understanding. So start a new post in the French forum. If you quote “Polylang” in your post, I should be able to find it.

    Thread Starter karpediem

    (@karpediem)

    Ok, I made it. Just a problem, I wrote “Polylangue” instead of “Polylang” ;o)
    Thank you !

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Afficher les posts dans la langue par défaut si pas de traduction’ is closed to new replies.