Languages get mixed on wp_query [ Polylang ]
-
Hi there,
I’m facing a mix of content on a wp_query.
I’m using the plugin Polylang with two languages.
Here is the code I’m working on :
<?php global $wp_query; $exclude = $wp_query->post->ID; $cat_ID = get_the_category($post->ID); $post_cat = $cat_ID[0]->cat_ID; $args = array( 'cat' => - $post_cat, 'posts_per_page' => 2, 'orderby' => 'rand' ); $your_query = new WP_Query( $args ); /* loop */ echo '<ul>'; while( $your_query->have_posts() ) : $your_query->the_post(); if( $exclude != get_the_ID() ) { echo '<li><a href="' . get_permalink() . '">' . get_the_excerpt() . '</a></li>'; } endwhile; echo '</ul>'; ?>OR but same issue :
<?php $post_id = get_the_ID(); $category = get_the_category(); $post_cat = '-'.$category[0]->cat_ID ; $args = array( 'cat' => $post_cat, 'orderby' => 'rand', 'posts_per_page' => 2, 'post__not_in' => array( $post_id ) ); $rand_query = new WP_Query( $args ); echo '<ul>'; while ( $rand_query->have_posts() ) : $rand_query->the_post(); echo '<li><a href="'.get_permalink().'" title="'.the_title('','',false).'">'; echo get_the_excerpt(); echo '</a></li>'; endwhile; echo '</ul>'; ?>The current post is exclude on the display posts. But, on the two posts, the both languages are coming up.
In the same time, I want to exclude the category of the current post which is not working neither.
Any though to fix that is welcome.
Thanks a lot
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Languages get mixed on wp_query [ Polylang ]’ is closed to new replies.