Lists posts in current category and mqTranslate (4 posts)

  1. Ismael Latorre
    Posted 8 months ago #

    Quick question: In single.php I am listing all other posts in the category except the current one. Problem is, mqTranslate is listing all posts in the category in all languages. How can I list just posts in the current category only in the current language?

    This is the sidebar code I am using:

    <?php $orig_post = $post;
        global $post;
        $categories = get_the_category($post->ID);
        if ($categories) {
        $category_ids = array();
        foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
        'category__in' => $category_ids,
        'post__not_in' => array($post->ID),
        'posts_per_page'=> 20, // Number of related posts that will be shown.
        $my_query = new wp_query( $args );
        if( $my_query->have_posts() ) {
        echo '<div class="related_posts">';
        while( $my_query->have_posts() ) {
         <div class="related-items">
        <li class="relatedcontent-side">
        <a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
        echo '</div>';
        $post = $orig_post;
        wp_reset_query(); ?>


  2. Ismael Latorre
    Posted 7 months ago #

    No answer... Anyone can please point me in the right direction? This is a fairly basic thing, I am sure, but I cannot find the solution! Please help!

  3. Eccola
    Posted 7 months ago #

    Hello Ismael,

    you could try adding a qtranslate conditional into your loop, ex.:


    <li class="relatedcontent-side">
    <?php if(qtrans_getLanguage()=='fi'): ?>
    <a href="<?php the_permalink()?>" rel="bookmark" title="<?php _e("[:fi] the_title()"); ?>"><?php _e("[:fi] the_title()"); ?></a>
    <?php elseif(qtrans_getLanguage()=='sv'): ?>
    <a href="<?php the_permalink()?>" rel="bookmark" title="<?php _e("[:sv] the_title()"); ?>"><?php _e("[:sv] the_title()"); ?></a>
    <?php endif; ?>


    also, check the while{} output logic.

  4. Ismael Latorre
    Posted 7 months ago #

    I haven't explained myself correctly:

    Some posts within each category are only in English, some are only in Swedish, and some are both in English and in Swedish. What I am trying to achieve is, in single.php, a list of the category posts, except the current single post, ONLY in the current language. I get a mixture of both languages in the list.

    Conditional solutions like the above would only help when posts are translated into both languages.


You must log in to post.

About this Plugin

About this Topic