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 1 reply, has 2 voices.

Last updated by Bruno Kos 6 months, 3 weeks ago.

Assigned support staff: Bruno Kos.

Author Posts
March 20, 2019 at 8:22 pm #3393195

Fernando

Hello this is the code in a custom post type single page that need to show a list of post selected via acf relationship post type.

<div id="section-posts" style="background-color:#f9f9f9;">
						        <?php if( get_field('sec_posts') ): // Posts Français ?>
    						        <strong class="sec-subtitle"><?php _e("Publications", "SDAQC");?></strong>
    						        <div style="margin:20px 0;padding:12px;">
            							<?php $sec_posts = get_field( 'sec_posts',$original_id); ?>
            							
            							<?php if ( $sec_posts && ICL_LANGUAGE_CODE=='fr' ): // french ?>
            								<?php foreach ( $sec_posts as $post ):  ?>
            									<?php setup_postdata ( $post ); ?>
            									<?php
										$post_cat = get_the_tags(); //get the tags of this post
										$cat_name = $post_cat[0]->name; //get the name of the first category
										?>
								<div class="<?php echo $cat_name; ?> pubs">
									<a href="<?php the_permalink(); ?>"><p><?php the_title(); ?></p></a>
									<p><small class="entry-date"><?php echo get_the_date(); ?></small></p>
								</div>
            							<?php endforeach; ?>
            							<?php wp_reset_postdata(); ?>
            							<?php endif; // french end ?>
            							
            								<?php if ( ICL_LANGUAGE_CODE=='en' ): // english ?>
            								<?php foreach ( $sec_posts as $post ):  ?>
            								    <?php $post2 = apply_filters( 'wpml_object_id', $post, 'post'  ); // English variable ?>
            									<?php setup_postdata ( $post2 ); ?>
            									<?php
										$post_cat = get_the_tags(); //get the tags of this post
										$cat_name = $post_cat[0]->name; //get the name of the first category
										?>
								<div class="<?php echo $cat_name; ?> pubs">
									<a href="<?php the_permalink(); ?>"><p><?php the_title(); ?></p></a>
									<p><small class="entry-date"><?php echo get_the_date(); ?></small></p>
								</div>
            							<?php endforeach; ?>
            							<?php wp_reset_postdata(); ?>
            							<?php endif; // english end ?>
							</div>
        						<?php endif; ?>
    						</div>

I expected to see the translated titles when I click to the english version,

Instead, I got the french title with the right url to the translated post.

Please advise

March 21, 2019 at 9:30 am #3397343

Bruno Kos
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hi,

In order to debug this issue further quickly, would you be willing to provide me with temporary WordPress admin username so I could investigate the issue directly? I have marked your next reply private so you can safely add this information.

Also, can you send me the link of the post where I see this happening?

https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

Please make a full backup of your site before sharing this info!

You can use plugins such as UpdraftPlus WordPress Backup Plugin (https://wordpress.org/plugins/updraftplus/) or ask your host to perform a site backup.

Regards,
Bruno Kos

The topic ‘[Closed] Translating the_title of a post using acf post_object field’ is closed to new replies.