• Resolved kaderm

    (@kaderm)


    Hi
    I would like to know how -in the template- to use my wp_query to show only posts in X language.

    Url : https://www.food-intolerance.ca/food-intolerance/fr/

    the piece of code I use to show the “recent articles” in the bottom of every columns is the following :

    <?php $recent = new WP_Query("cat=7&showposts=5"); while($recent->have_posts()) : $recent->the_post();?>
    			<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    			<?php endwhile; ?>

    How do I specify “show only posts that have the language_id = 2 (1 being english and 2 being french)

    I use WP 2.1.2 and Gengo 0.9

Viewing 5 replies - 1 through 5 (of 5 total)
  • moshu

    (@moshu)

    Hmm… on a Wp 2.0.11 + Gengo 0.8 I don’t have to do anything: depending on the language choice of the visitor a similar code always displays ONLY the recent posts in the language that is viewed.
    The code:

    <?php query_posts('showposts=10'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            <li><a href="<?php the_permalink() ?>">
              <?php the_time('n.j') ?>
    
              <?php the_title() ?>
              </a></li>
    <?php endwhile; endif; ?>

    See it here – middle column in the red footer; change the lang with the flags (top left)

    Thread Starter kaderm

    (@kaderm)

    It worked !!!

    I reworked it (adding a category id)
    <?php query_posts(‘cat=7&showposts=5’); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    I’m using a list like this on one of my clients site.

    But I encounter a strange issue. The query and filtering is working fine on every page and post.

    EXCEPT on my landingspage it’s going completely wrong; it lists all my posts with all the languages mixed.

    The landingspage is a static page, and I’m quite sure it is because I setup my wordpress to display this static page as the front page instead of the list of posts it normally shows, that things are going wrong. It’s just like with this setup Gengo doesn’t know which language the page is in .

    Anyone any idea on solving this?

    Thanks in advance.

    This is the php code to show the list, and I’m using Gengo2.5 alpha on WP2.5.1

    <?php query_posts('showposts=3&cat=4'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="list-item">
    <a href="<?php the_permalink(); ?>" rel="bookmark" title="Read more about <?php the_title(); ?>"><img class="left" height="60" width="90" src="<?php echo get_option('home'); ?>/wp-content/media/<?php
    $values = get_post_custom_values("Image"); echo $values[0]; ?>" /></a>
    <div class="description"><h4><a href="<?php the_permalink(); ?>" rel=”bookmark”>
    <?php
    the_title(); ?></a></h4></div><div class="clear"></div>
    </div>
    <?php endwhile; ?>

    query_posts is unfiltered, actually. Try using another query object instead.

    https://codex.www.ads-software.com/The_Loop (near to the bottom).

    pixline,

    can u instruct me how to use other query string to replace query_posts?

    i couldnt find anything in above link

    thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Listing Post depending on their language_id (with Gengo)’ is closed to new replies.