This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

No supporters are available to work today on this forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 24 replies, has 3 voices.

Last updated by sarah.n 5 years, 9 months ago.

Assigned support staff: sarah.n.

Author Posts
October 19, 2013 at 1:20 pm #279373

Asa

Hello,

We have issue when the option "All posts (display translation if it exists or posts in default language otherwise)." is active. With Posts work good, but with Custom Post Type show only selected language instead of selected and original (if translation don't exist).

I'm download last version od WPML and issue still takes.

Can you help me please. Thanks

October 20, 2013 at 9:29 am #279474

Harshad

Dear Asa,

The option will only work for default post type on Blog page.

To display all posts of custom post type on Archive page, please add the following code to the page template in your theme which displays the Custom post type.

<?php
global $sitepress;
remove_filter('posts_join', array($sitepress,'posts_join_filter'), 10, 2);
remove_filter('posts_where', array($sitepress,'posts_where_filter'), 10, 2);
?>
October 21, 2013 at 9:05 am #279788

Asa

Hi Harshad,

thanks for your answer.

I use your code but nothing changes. Still ares displayed only PT-BR posts -> hidden link

Here is my template:

 
<?php
/**
 * The main template file.
 *
 * This is the most generic template file in a WordPress theme and one of the
 * two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * For example, it puts together the home page when no home.php file exists.
 *
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Twenty_Thirteen
 * @since Twenty Thirteen 1.0
 */

get_header(); ?>
<?php get_sidebar('home'); ?>

<section id="content" class="frontpage">
	<?php 
	/******************************/
	/* Feed
	/******************************/
	?>
	<div class="feedList site-content" role="main">
		<?php 

		global $sitepress;
		remove_filter('posts_join', array($sitepress,'posts_join_filter'), 10, 2);
		remove_filter('posts_where', array($sitepress,'posts_where_filter'), 10, 2);

		$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

		$args =	array( 
				'posts_per_page' => 5, 
				'post_status'    => 'publish',
				'post_type'      => array('project','services','now_news'), 
				'suppress_filters'  => 0,
				'orderby'        => 'date', 
				'paged'          => $paged, 
				'order'          => 'DESC', 
				'tag'            => 'Home' 
			);

		$posts = new WP_Query( $args );
		?>
		<?php 
		if ( $posts->have_posts() ) :
			while ( $posts->have_posts() ) : $posts->the_post();
				get_template_part( 'content', 'article' );
			endwhile;
			twentythirteen_paging_nav(); 
		else :
			get_template_part( 'content', 'none' );
		endif; 
		?>
		<?php wp_reset_postdata(); ?>					
	</div>
</section>		

<?php get_footer(); ?>

Thanks

October 21, 2013 at 9:24 am #279808

Harshad

Can you please pass suppress_filters => true as argument to your query
For ex.

$args = array(
                'posts_per_page' => 5,
                'post_status'    => 'publish',
                'post_type'      => array('project','services','now_news'),
                'suppress_filters'  => 0,
                'orderby'        => 'date',
                'paged'          => $paged,
                'order'          => 'DESC',
                'tag'            => 'Home',
                'suppress_filters' => true
            );
 
October 21, 2013 at 10:04 am #279834

Asa

I try it, but without effect again.

October 21, 2013 at 10:50 am #279874

Harshad

Dear Asa,

For testing can you please disable other plugins, keep only WPML and addon plugins enabled?

October 21, 2013 at 12:27 pm #279958

Asa

Hi Harshad,

for testing i make new installation of WordPress (3.6.1) (without others plugins) and WPML (2.9.3). This is my code of category.php:

<?php
/**
 * The template for displaying Category pages.
 *
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Twenty_Thirteen
 * @since Twenty Thirteen 1.0
 */

get_header(); 

global $sitepress;
remove_filter('posts_join', array($sitepress,'posts_join_filter'), 10, 2);
remove_filter('posts_where', array($sitepress,'posts_where_filter'), 10, 2);

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

$args =	array( 
		'suppress_filters' => true,
		'posts_per_page'   => 15, 
		'post_status'      => 'publish',
		'post_type'        => array('people'), 
		'orderby'          => 'date', 
		'paged'            => $paged, 
		'order'            => 'DESC' 
	);

$posts = new WP_Query( $args );
?>

	<div id="primary" class="content-area">
		<div id="content" class="site-content" role="main">

		<?php if ( $posts->have_posts() ) : ?>
			<header class="archive-header">
				<h1 class="archive-title"><?php printf( __( 'Category Archives: %s', 'twentythirteen' ), single_cat_title( '', false ) ); ?></h1>

				<?php if ( category_description() ) : // Show an optional category description ?>
				<div class="archive-meta"><?php echo category_description(); ?></div>
				<?php endif; ?>
			</header><!-- .archive-header -->

			<?php /* The loop */ ?>
			<?php while ( $posts->have_posts() ) : $posts->the_post(); ?>
				<?php get_template_part( 'content', get_post_format() ); ?>
			<?php endwhile; ?>

			<?php twentythirteen_paging_nav(); ?>

		<?php else : ?>
			<?php get_template_part( 'content', 'none' ); ?>
		<?php endif; ?>

		</div><!-- #content -->
	</div><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>
 

In this category shows all posts from all languages instead of avanti.code.cz, where show posts from current language. Any idea?

Thanks

October 21, 2013 at 12:54 pm #279983

Harshad

So does it work on test installation?

Can you please try this on your main site:
go to wordpress admin -> wpml -> support, click on the troubleshooting link at the bottom of the page.

On troubleshooting page
1) Click "Remove ghost entries from translations table" button
2) Click "General clean up" button
3) Click "Set language information" button.

October 21, 2013 at 1:22 pm #280004

Asa

Sorry, no. On the test installation work bad, but different of main site.
On test shows all posts from all languages. Ie. original post and all his others translations. It seems that this affects "'tag' => 'Home'" in arguments.

October 21, 2013 at 1:33 pm #280022

Harshad

Did you translate tag "Home"?

October 21, 2013 at 2:15 pm #280055

Asa

Yes, sure.

I've upload test instalation on server.
Here is Category without tag in template: hidden link

global $sitepress;
remove_filter('posts_join', array($sitepress,'posts_join_filter'), 10, 2);
remove_filter('posts_where', array($sitepress,'posts_where_filter'), 10, 2);

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

$args =	array( 
		'suppress_filters' => true,
		'posts_per_page'   => 15, 
		'post_status'      => 'publish',
		'post_type'        => array('people'), 
		'orderby'          => 'date', 
		'paged'            => $paged, 
		'order'            => 'DESC'
	);

$posts = new WP_Query( $args );

and here with tag hidden link

global $sitepress;
remove_filter('posts_join', array($sitepress,'posts_join_filter'), 10, 2);
remove_filter('posts_where', array($sitepress,'posts_where_filter'), 10, 2);

$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

$args =	array( 
		'suppress_filters' => true,
		'posts_per_page'   => 15, 
		'post_status'      => 'publish',
		'post_type'        => array('people'), 
		'orderby'          => 'date', 
		'paged'            => $paged, 
		'order'            => 'DESC',
		'tag' => 'Home'
	);

$posts = new WP_Query( $args );

Both versions behave wrong.
Can you send access to WP admin?

Thanks

October 23, 2013 at 1:18 pm #281224

Harshad

Can you use tag__in instead and pass the tag_id in combination with icl_object_id() function.

$args = array(
        'suppress_filters' => true,
        'posts_per_page'   => 15,
        'post_status'      => 'publish',
        'post_type'        => array('people'),
        'orderby'          => 'date',
        'paged'            => $paged,
        'order'            => 'DESC',
        'tag__in' => icl_object_id(10,'tag',false,ICL_LANGUAGE_CODE)
    );
October 25, 2013 at 9:01 am #282126

Asa

Hi Harshad,

Now it behaves consistently. But still wrong.

So category With tag hidden link

In English should be posts:
Three
Two
One

In German should be posts:
Drei
Zwei
One

------------------------

BUT

In English are posts:
Drei
Three
Zwei
Two
One

In German are posts:
Drei
Zwei

That's the main issue.

Thanks for your support.

October 25, 2013 at 11:06 am #282209

Harshad

Change suppress_filters => false

$args = array(
        'suppress_filters' => false,
        'posts_per_page'   => 15,
        'post_status'      => 'publish',
        'post_type'        => array('people'),
        'orderby'          => 'date',
        'paged'            => $paged,
        'order'            => 'DESC',
        'tag__in' => icl_object_id(10,'tag',false,ICL_LANGUAGE_CODE)
    );
October 25, 2013 at 1:08 pm #282258

Asa

Unfortunately, without change :/

The topic ‘[Closed] Blog posts to display – All posts (….) – CPT bug’ is closed to new replies.