Filter language in query_posts?

dev.xiligroup est en travaux Forums xili-language plugin Filter language in query_posts?

Ce sujet contient 0 réponses et 6 voix, et a été mis à jour par  xiligroup dev il y a Il y a 11 ans, 7 mois.

Visualisation du message 9 (1 sur 9, 9 au total)
  • Auteur
    Articles
  • #2910

    Anonyme

    Hello Floren,

    xili-language taxonomy since the very first time of his creation preserves the core architecture and add a query_tag named ‘lang’. So for a special query post, it is easy like below :

    $args = array(
    'cat' => 480,
    'year' => '2009',
    'monthnum' => '05',
    'order' => 'ASC',
    'lang' => 'en_us'
    );
    query_posts( $args );

    where only posts of a category at good month (may) in english will be displayed…

    Good luck

    #2915

    Anonyme

    Hello, the solution looks easy… but doesn’t works for me.

    I would like to display only post of the selected language.

    The whole page is correctly translated but it always display post of any language.

    #2916

    Anonyme

    Is it the only loop inside the displayed webpage ? Can you show the array of the query ?

    #2918

    Anonyme

    here is the simplified code of my page :

    <?php get_header(); ?>
    <div class="SC">
    <div class="co3">
    <div class="actu-droite">
    <h3><?php _e('ACTU','DBG');?></h3>
    <?php
    $args = array('lang' => 'en_us' );
    $myposts = get_posts( $args );
    foreach($myposts as $post) : setup_postdata($post);
    ?>
    <div class="actu">
    <div class="p-head">
    <h3><a href="<?php the_permalink(); ?>"><?php the_title()?></a></h3>
    </div>
    <div class="p-con">
    <p class="p-date-cat"><?php the_time('j-m-y') ?> | <?php _e('In:','DBG');?> <?php the_category(', ') ?></p>
    <p><?php echo truncate($post->post_content,256); ?></p>
    </div>
    <ul class="p-det">
    <li class="p-det-com"><?php comments_popup_link(__('No Comments','DBG'), __('(1) Comment','DBG'), __('(%) Comments','DBG')); ?></li>
    <li class="p-det-more"><a href="<?php the_permalink()?>"><?php _e('More...','DBG');?></a></li>
    </ul>
    <?php endforeach; ?>
    </div>
    </div>
    </div>
    <?php get_footer(); ?>

    Every text displayed with _e is translated in the correct language.

    #2919

    Anonyme

    Ok sorry i’m dumb, i was using get_posts() instead of query_posts()

    #3126

    Anonyme

    I tried this but had not luck, any ideas on fixing it. Using the latest WP3.4.1 and latest XILI-Language:

    <?php

    $args = array(

    ‘cat’ => 12,

    ‘numberposts’ => 20,

    ‘orderby’ => ‘date’,

    ‘order’ => ‘DESC’,

    ‘post_type’ => ‘post’,

    ‘post_status’ => ‘publish’,

    ‘lang’ => the_curlang()

    );

    $postslist = get_posts( $args );

    foreach($postslist as $post):

    setup_postdata($post);?>

    <?php the_field(‘story’); ?>

    <hr>

    <?php endforeach;?>

    #3127

    xiligroup dev
    Keymaster

    As Lozit said, you must use query_posts() function or use new wp_query – see full doc http://codex.wordpress.org/Function_Reference/WP_Query

    You can also use xili_postinpost plugin that provides a secure way….

    #3131

    Anonyme

    I created multi site in wordpress using xili language plugin. Site has blog too. Site main language is Italian, when I click on Blog menu it landed to Spanish site. Please check following url

    http://pixelpc.comli.com/

    I check current language by following function, it shows es_es

    the_curlang()

    I want If I click Blog menu on Italian site then Blog menu must be Italian, If I am on English site and click on Blog menu then menu must be English same as Spanish site.

    Hope you understand. I need its solution urgently. Please reply me soon

    #3152

    xiligroup dev
    Keymaster

    visiting your site seems that you find yourself the solution – please share your experience !

Visualisation du message 9 (1 sur 9, 9 au total)

Vous devez être connecté pour répondre à ce sujet.