Please make sure to update to WPML 4.3.6 and check our list of Known Issues before reporting

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.

This topic contains 5 replies, has 2 voices.

Last updated by Anonymous 7 years, 11 months ago.

Author Posts
January 27, 2012 at 8:43 am #46291

Nohemi

Hello,
I've almost finished a website for a customer and I'd like to add WPML to it. I activated :
- WPML Multilingual CMS
- WPML String Translation
- WPML Translation Management
and started configuring the plugin. Then I got back to the frontend and figured out my pages all got content doubled. I mean I still have the same number of pages but my loop (native loop called in page.php) loops 2 times instead of one.
My code is the original one :
while ( have_posts() ) : the_post();
// Awesome thing I code as usual 😉
endwhile;
I've tried almost every single solution I found but couldn't make it word. I'd love not to have to choose another plugin since I already use WPML on several customer websites.
Any help would be appreciated.
PS : website running under WP 3.3.1 and last version of WPML of course

January 27, 2012 at 8:47 am #46293

Anonymous

Hi Nohemi,
Please paste here the full code responsible for displaying those posts.

January 27, 2012 at 1:50 pm #46294

Nohemi

Here it is:
<?php
$redirect = getFirstChild( get_the_ID() );
if( in_array( get_the_ID(), array( 10, 30, 24, 42, 56 ))) {
header( 'Location:'.$redirect );
exit();
}
get_header(); ?>
<div id="container">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post();
$currentId = get_the_ID();
createBreadcrumb();
?>
<div id="left-column" class="parent-page-<?php echo $post->post_parent == 0 ? the_ID() : $post->post_parent; ?>">
<ul id="left-menu">
<?php
$parentId = $post->post_parent == 0 ? get_the_ID() : $post->post_parent;
$firstChild = new WP_Query( 'post_parent='.$parentId.'&posts_per_page=0&orderby=menu_order&post_type=page' );
if( $firstChild->have_posts() ) while( $firstChild->have_posts() ) : $firstChild->the_post();
echo '<li'.( $currentId == get_the_ID() ? ' class="current-page-item"' : '' ).'><a href="'.get_permalink().'">'.get_the_title().'</a>';
endwhile;
wp_reset_query();
?>
</div><!-- #left-column -->
<div id="right-column">
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content">
<?php the_content(); ?>
</div><!-- .entry-content -->
</div><!-- #post-## -->
</div><!-- #right-column -->
<?php endwhile; // End the loop. Whew. ?>
</div><!-- #content -->
</div><!-- #container -->
<?php get_footer(); ?>

January 27, 2012 at 2:14 pm #46295

Anonymous

Instead of wp_reset_query();
use
wp_reset_postdata();

January 27, 2012 at 4:42 pm #46296

Nohemi

Thanks it worked!

January 28, 2012 at 8:44 am #46297

Anonymous

Great.

The topic ‘[Closed] Pages content doubled’ is closed to new replies.