Skip Navigation

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 9:00 – 14:00 -
- 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 15:00 – 18:00 -

Supporter timezone: Asia/Dhaka (GMT+06:00)

This topic contains 8 replies, has 3 voices.

Last updated by Prosenjit Barman 7 months, 2 weeks ago.

Assisted by: Prosenjit Barman.

Author Posts
July 8, 2024 at 2:26 pm #15913909

Chad Warner

Background of the issue:
I am trying to display content on my site hidden link. Specifically, on the page hidden link, which shows a custom CPT named People.
Here's the file that builds this page:

get_header(); ?>


<?php
echo '

';
?>

ID);
echo apply_filters('the_content',$content);
?>

Symptoms:
Occasionally, the page shows a few duplicates (a few duplicate photos, with content in French) instead of only English content.

Questions:
Why is the page showing duplicate photos with content in French?
How can I ensure that only English content is displayed on the page?

July 8, 2024 at 2:28 pm #15913982

Chad Warner

It looks like the code I pasted was modified by your system. Please let me know if I should provide it another way.

July 9, 2024 at 7:55 am #15918696

Marcel
Supporter

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+01:00)

Hi,

Before your ticket is assigned to one of my colleagues, please allow me to guide you through some initial debugging steps to help speed up the support process.

Yes, you can try posting it again in your next reply; then, nothing should be cut inside a second reply.

Additionally, please make sure that your WP_Query includes the following line:

'suppress_filters' => false,

Best regards,
Marcel

July 9, 2024 at 2:40 pm #15921489

Chad Warner

No,

'suppress_filters' => false,

isn't present. Please let me know where it should be added in the code below. Alternatively, I can send the template file or give you SFTP access.

<?php

get_header(); ?>

  <?php get_template_part( 'template-parts/people/people', 'archive-header' ); ?>
  
  <?php get_template_part( 'template-parts/people/people', 'filter' ); ?>

  <?php if ( have_posts() ) { ?>

  <div id="ajax-container">
    <div class="people-listing js-ajax-content">
    <?php while ( have_posts() ) : the_post(); ?>
  
      <?php get_template_part( 'template-parts/people/person', 'teaser' ); ?>
  
    <?php endwhile; ?>
    
    </div><!--js-ajax-content-->
    <?php
    echo '<div class="pagination button__wrapper--load-more js-next-container js-load-more">';
      //posts_nav_link('','Go Back','Load More');
      //next_posts_link('Load More');
      $nextlink = get_next_posts_link('Load More');
      echo $nextlink;
      /*
      preg_match_all('~<a(.*?)href="([^"]+)"(.*?)>~', $nextlink, $matches);
      $href = $matches[2][0];
      $needle = '/page/';
      $url = parse_url($href);
      print_r($url);
      // If page is in the URL, change to get var.
      if (strpos($href, $needle) !== false) {
        
      }
*/
    echo '</div>';
    ?>
  
  </div><!-- ajax-container-->
  
  
  
  <?php } else { ?>
  
    
  
  <?php } ?>
  
  <?php
  // Display blocks
  $pageid = get_page_by_title('Leadership');
  $content = get_the_content('','',$pageid->ID);
  echo apply_filters('the_content',$content);
  ?>
  
<?php get_footer(); ?>
July 10, 2024 at 4:31 am #15925112

Prosenjit Barman
Supporter

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hi There,

I hope you're doing well. I have taken over this ticket and will be happy to assist you further in this matter.

To include `'suppress_filters' => false` in your code, you need to add it to the appropriate query parameters. This is usually necessary when using functions like `get_posts` or `WP_Query`. You can open the teaser template (`template-parts/people/person`) and check the query defined there. If you can share the code from that template, I can also guide you on how to add that filter.

However, I checked the `Leadership` page and can see that all the images are now showing only once. I haven't noticed any duplicates. If the issue is happening randomly, it would also be better to check by clearing the caches from your site and browser.

Let me know if the information above helps or if you need further assistance in this matter. I will be happy to help.

Best regards,
Prosenjit

July 10, 2024 at 2:27 pm #15928610

Chad Warner

The French content only shows on the English page once in a while, and we can't replicate the problem on command. It's possible it's a caching issue, but the cached copy of the English page shouldn't ever contain French content, right?

Here's the code from /template-parts/people/person-teaser.php:

<?php
// Variables
$id = get_the_ID();
$newsimage = get_field('person_headshot',$id);
$categories = get_the_category($id);
$terms = '';
$slug = get_post_field( 'post_name', $id);
foreach ($categories as $key => $cat) {
	$sep = ($key == 0) ? '' : ', ';
	$terms .= $sep.'<span class="news-item__category type__caps">'.$cat->name.'</span>';
}

// Output
echo '<article class="person-teaser js-item">';
	echo '<a class="a-image js-bio slug" data-id="'.$id.'" href="/leadership/'.$slug.'" data-url="'.get_the_permalink($id).'" data-slug="bio--'.$slug.'" data-title="'.get_the_title($id).' - '.get_bloginfo('site_title').'">';
		echo '<figure class="image portrait">';
			echo '<img src="'.$newsimage['sizes']['medium'].'" alt="'.$newsimage['alt'].'" />';
		echo '</figure>';
	echo '</a>';
	
	echo '<div class="project-teaser__summary">';
		echo '<h4 class="type__heading-four"><a class="a-tab-small js-bio slug" data-id="'.$id.'" href="/leadership/'.$slug.'" data-url="'.get_the_permalink($id).'" data-slug="bio--'.$slug.'" data-title="'.get_the_title($id).' - '.get_bloginfo('site_title').'">'.get_the_title($id).'</a></h4>';
		echo '<span class="person-position type__caps">'.get_field('person_position_title',$id).'</span>';
	echo '</div>';
echo '</article>';
?>
July 11, 2024 at 5:33 am #15932166

Prosenjit Barman
Supporter

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hi There,
Thank you for the update.

Based on the provided template code, it looks fine. The data being displayed is a combination of post details, categories, and custom fields. Since you're not querying any posts directly in this template, I don't think the `suppress_filters` parameter is required.

However, while checking the WPML Debug info, I noticed that a certain post type is set to "Translatable - use translation if available or fallback to default language." If the persons you're displaying are part of a post type that is set to display as a fallback, you may encounter this issue. Please set the post type associated with the Person to "Translatable - only show translated items" by going to "WPML > Settings > Post Type Translation." Once done, please continue to monitor if the issue is happening again or not.

Additionally, if object caching or server-level caching is enabled, please clear those caches. While cache is typically stored for each language version, it is always best to clear them to ensure they are not causing the problem

For your information, I took another look from a different browser and can confirm that the persons are now showing correctly on the page. But, please feel free to let me know if you need further assistance or clarification on any point. I will be happy to help.

Best regards,
Prosenjit

July 15, 2024 at 1:57 pm #15954869

Chad Warner

Thanks. I'm waiting for the site owner to make a decision about choosing "Translatable - only show translated items" because some content isn't yet translated.

July 16, 2024 at 5:32 am #15957996

Prosenjit Barman
Supporter

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hi!

Thank you for the update. Feel free to let me know if you need further assistance in this matter. I will be happy to help.

Best regards,
Prosenjit

The topic ‘[Closed] Content showing in English and French, instead of only English’ is closed to new replies.