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 19 replies, has 2 voices.

Last updated by Shekhar Bhandari 2 months, 2 weeks ago.

Assigned support staff: Shekhar Bhandari.

Author Posts
July 15, 2019 at 9:48 pm

jasonM-25

This is a followup to https://wpml.org/forums/topic/translated-fields-display-on-original-language-page-but-not-translated-page/#post-4214685, as it got marked resolved prematurely.

I am trying to: Display translated fields in my custom theme.

Link to a page where the issue can be seen: hidden link <-- original
hidden link <-- translated

I expected to see: Translated fields being output

Instead, I got: Translated fields are not being displayed

On my local, I've messed around with the code on the backend. I've got an ACF repeater field on the homepage, which is outputting fine on the original English page but is not appearing on the translated page. (The fields are appearing on the translation edit page, and have been translated.) I tried getting some more info using my php template file:

var_dump($post->get_field('highlights'));

On the original English version of the page I'm seeing the following output:

/Users/noxlady/Sites/climate-breakthrough-project/wp-content/themes/radicati/template-home.php:16:
array (size=2)
  0 => 
    array (size=6)
      'highlight_tag' => string 'About' (length=5)
      'highlight_title' => string 'Progress isn't enough. We need breakthroughs.' (length=47)
      'highlight_subtitle' => string '' (length=0)
      'highlight_content' => string '<p>We are losing the race to prevent the most catastrophic impacts of global warming. Efforts to address the crisis simply have not been enough. The planet needs new transformative strategies.</p>
<p>The Climate Breakthrough Project finds extraordinary strategists and gives them the time, space, and resources to create and implement the boldest strategies they can conceive to mitigate climate change.</p>
' (length=408)
      'highlight_button' => 
        array (size=4)
          'label' => string 'Read More' (length=9)
          'type' => string 'post' (length=4)
          'link' => 
            array (size=3)
              'title' => string '' (length=0)
              'url' => string '<em><u>hidden link</u></em>' (length=56)
              'target' => string '' (length=0)
          'page' => string '<em><u>hidden link</u></em>' (length=47)
      'highlight_media' => 
        array (size=3)
          'media_type' => string 'image' (length=5)
          'image' => 
            array (size=24)
              'ID' => int 367
              'id' => int 367
              'title' => string 'iStock-852285320_high_thumb' (length=27)
              'filename' => string 'iStock-852285320_high_thumb.jpg' (length=31)
              'filesize' => int 977804
              'url' => string '<em><u>hidden link</u></em>' (length=99)
              'link' => string '<em><u>hidden link</u></em>' (length=74)
              'alt' => string '' (length=0)
              'author' => string '3' (length=1)
              'description' => string '' (length=0)
              'caption' => string '' (length=0)
              'name' => string 'istock-852285320_high_thumb' (length=27)
              'status' => string 'inherit' (length=7)
              'uploaded_to' => int 4
              'date' => string '2018-05-14 17:42:39' (length=19)
              'modified' => string '2018-06-19 19:17:26' (length=19)
              'menu_order' => int 0
              'mime_type' => string 'image/jpeg' (length=10)
              'type' => string 'image' (length=5)
              'subtype' => string 'jpeg' (length=4)
              'icon' => string '<em><u>hidden link</u></em>' (length=77)
              'width' => int 2000
              'height' => int 1335
              'sizes' => 
                array (size=72)
                  'thumbnail' => string '<em><u>hidden link</u></em>' (length=107)
                  'thumbnail-width' => int 150
                  'thumbnail-height' => int 150
                  'medium' => string '<em><u>hidden link</u></em>' (length=107)
                  'medium-width' => int 300
                  'medium-height' => int 200
                  'medium_large' => string '<em><u>hidden link</u></em>' (length=107)
                  'medium_large-width' => int 768
                  'medium_large-height' => int 513
                  'large' => string '<em><u>hidden link</u></em>' (length=108)
                  'large-width' => int 1024
                  'large-height' => int 684
                  'site-logo' => string '<em><u>hidden link</u></em>' (length=107)
                  'site-logo-width' => int 350
                  'site-logo-height' => int 234
                  'site-logo-2x' => string '<em><u>hidden link</u></em>' (length=107)
                  'site-logo-2x-width' => int 700
                  'site-logo-2x-height' => int 467
                  'highlight-item' => string '<em><u>hidden link</u></em>' (length=107)
                  'highlight-item-width' => int 600
                  'highlight-item-height' => int 394
                  'highlight-item-2x' => string '<em><u>hidden link</u></em>' (length=108)
                  'highlight-item-2x-width' => int 1200
                  'highlight-item-2x-height' => int 788
                  'foundation-thumbnail' => string '<em><u>hidden link</u></em>' (length=107)
                  'foundation-thumbnail-width' => int 300
                  'foundation-thumbnail-height' => int 200
                  'foundation-thumbnail-2x' => string '<em><u>hidden link</u></em>' (length=107)
                  'foundation-thumbnail-2x-width' => int 600
                  'foundation-thumbnail-2x-height' => int 401
                  'slider-thumbnail' => string '<em><u>hidden link</u></em>' (length=107)
                  'slider-thumbnail-width' => int 300
                  'slider-thumbnail-height' => int 300
                  'slider-thumbnail-2x' => string '<em><u>hidden link</u></em>' (length=107)
                  'slider-thumbnail-2x-width' => int 600
                  'slider-thumbnail-2x-height' => int 600
                  'awardee-slider-thumbnail' => string '<em><u>hidden link</u></em>' (length=107)
                  'awardee-slider-thumbnail-width' => int 350
                  'awardee-slider-thumbnail-height' => int 309
                  'awardee-slider-thumbnail-2x' => string '<em><u>hidden link</u></em>' (length=107)
                  'awardee-slider-thumbnail-2x-width' => int 700
                  'awardee-slider-thumbnail-2x-height' => int 618
                  'header-image' => string '<em><u>hidden link</u></em>' (length=109)
                  'header-image-width' => int 2000
                  'header-image-height' => int 1300
                  'header-image-2x' => string '<em><u>hidden link</u></em>' (length=99)
                  'header-image-2x-width' => int 2000
                  'header-image-2x-height' => int 1335
                  'awardee_headshot' => string '<em><u>hidden link</u></em>' (length=107)
                  'awardee_headshot-width' => int 668
                  'awardee_headshot-height' => int 446
                  'awardee_headshot-2x' => string '<em><u>hidden link</u></em>' (length=108)
                  'awardee_headshot-2x-width' => int 1336
                  'awardee_headshot-2x-height' => int 892
                  'staff_photo' => string '<em><u>hidden link</u></em>' (length=107)
                  'staff_photo-width' => int 750
                  'staff_photo-height' => int 501
                  'staff_photo-2x' => string '<em><u>hidden link</u></em>' (length=109)
                  'staff_photo-2x-width' => int 1500
                  'staff_photo-2x-height' => int 1001
                  'listing-image' => string '<em><u>hidden link</u></em>' (length=107)
                  'listing-image-width' => int 400
                  'listing-image-height' => int 400
                  'listing-image-2x' => string '<em><u>hidden link</u></em>' (length=107)
                  'listing-image-2x-width' => int 800
                  'listing-image-2x-height' => int 800
                  'gallery-image' => string '<em><u>hidden link</u></em>' (length=107)
                  'gallery-image-width' => int 667
                  'gallery-image-height' => int 355
                  'gallery-image-2x' => string '<em><u>hidden link</u></em>' (length=108)
                  'gallery-image-2x-width' => int 1334
                  'gallery-image-2x-height' => int 710
          'embed' => null
  1 => 
    array (size=6)
      'highlight_tag' => string 'Selection' (length=9)
      'highlight_title' => string 'We're looking for the world's best problem solvers.' (length=51)
      'highlight_subtitle' => string '' (length=0)
      'highlight_content' => string '<p>Breakthrough leaders solve problems by creating new solutions that overcome, or entirely circumvent, seemingly intractable barriers. We give US$2 million awards to individuals or small teams with a track record of successfully building new projects and an ability to think big. We want people who will have the vision and discipline to generate systemic change and make a global impact within ten years.</p>
' (length=411)
      'highlight_button' => 
        array (size=4)
          'label' => string 'Read More' (length=9)
          'type' => string 'post' (length=4)
          'link' => string '<em><u>hidden link</u></em>' (length=22)
          'page' => string '<em><u>hidden link</u></em>' (length=51)
      'highlight_media' => 
        array (size=3)
          'media_type' => string 'image' (length=5)
          'image' => 
            array (size=24)
              'ID' => int 230
              'id' => int 230
              'title' => string 'IMG_1376' (length=8)
              'filename' => string 'IMG_1376-2.jpg' (length=14)
              'filesize' => int 2178969
              'url' => string '<em><u>hidden link</u></em>' (length=82)
              'link' => string '<em><u>hidden link</u></em>' (length=57)
              'alt' => string '' (length=0)
              'author' => string '3' (length=1)
              'description' => string '' (length=0)
              'caption' => string '' (length=0)
              'name' => string 'img_1376-3' (length=10)
              'status' => string 'inherit' (length=7)
              'uploaded_to' => int 4
              'date' => string '2018-05-07 20:17:22' (length=19)
              'modified' => string '2018-05-24 21:23:17' (length=19)
              'menu_order' => int 0
              'mime_type' => string 'image/jpeg' (length=10)
              'type' => string 'image' (length=5)
              'subtype' => string 'jpeg' (length=4)
              'icon' => string '<em><u>hidden link</u></em>' (length=77)
              'width' => int 4032
              'height' => int 3024
              'sizes' => 
                array (size=72)
                  'thumbnail' => string '<em><u>hidden link</u></em>' (length=90)
                  'thumbnail-width' => int 150
                  'thumbnail-height' => int 150
                  'medium' => string '<em><u>hidden link</u></em>' (length=90)
                  'medium-width' => int 300
                  'medium-height' => int 225
                  'medium_large' => string '<em><u>hidden link</u></em>' (length=90)
                  'medium_large-width' => int 768
                  'medium_large-height' => int 576
                  'large' => string '<em><u>hidden link</u></em>' (length=91)
                  'large-width' => int 1024
                  'large-height' => int 768
                  'site-logo' => string '<em><u>hidden link</u></em>' (length=90)
                  'site-logo-width' => int 350
                  'site-logo-height' => int 263
                  'site-logo-2x' => string '<em><u>hidden link</u></em>' (length=90)
                  'site-logo-2x-width' => int 700
                  'site-logo-2x-height' => int 525
                  'highlight-item' => string '<em><u>hidden link</u></em>' (length=90)
                  'highlight-item-width' => int 600
                  'highlight-item-height' => int 394
                  'highlight-item-2x' => string '<em><u>hidden link</u></em>' (length=91)
                  'highlight-item-2x-width' => int 1200
                  'highlight-item-2x-height' => int 788
                  'foundation-thumbnail' => string '<em><u>hidden link</u></em>' (length=90)
                  'foundation-thumbnail-width' => int 300
                  'foundation-thumbnail-height' => int 225
                  'foundation-thumbnail-2x' => string '<em><u>hidden link</u></em>' (length=90)
                  'foundation-thumbnail-2x-width' => int 600
                  'foundation-thumbnail-2x-height' => int 450
                  'slider-thumbnail' => string '<em><u>hidden link</u></em>' (length=90)
                  'slider-thumbnail-width' => int 300
                  'slider-thumbnail-height' => int 300
                  'slider-thumbnail-2x' => string '<em><u>hidden link</u></em>' (length=90)
                  'slider-thumbnail-2x-width' => int 600
                  'slider-thumbnail-2x-height' => int 600
                  'awardee-slider-thumbnail' => string '<em><u>hidden link</u></em>' (length=90)
                  'awardee-slider-thumbnail-width' => int 350
                  'awardee-slider-thumbnail-height' => int 309
                  'awardee-slider-thumbnail-2x' => string '<em><u>hidden link</u></em>' (length=90)
                  'awardee-slider-thumbnail-2x-width' => int 700
                  'awardee-slider-thumbnail-2x-height' => int 618
                  'header-image' => string '<em><u>hidden link</u></em>' (length=92)
                  'header-image-width' => int 2000
                  'header-image-height' => int 1300
                  'header-image-2x' => string '<em><u>hidden link</u></em>' (length=92)
                  'header-image-2x-width' => int 4000
                  'header-image-2x-height' => int 2600
                  'awardee_headshot' => string '<em><u>hidden link</u></em>' (length=90)
                  'awardee_headshot-width' => int 657
                  'awardee_headshot-height' => int 493
                  'awardee_headshot-2x' => string '<em><u>hidden link</u></em>' (length=91)
                  'awardee_headshot-2x-width' => int 1315
                  'awardee_headshot-2x-height' => int 986
                  'staff_photo' => string '<em><u>hidden link</u></em>' (length=90)
                  'staff_photo-width' => int 750
                  'staff_photo-height' => int 563
                  'staff_photo-2x' => string '<em><u>hidden link</u></em>' (length=92)
                  'staff_photo-2x-width' => int 1500
                  'staff_photo-2x-height' => int 1125
                  'listing-image' => string '<em><u>hidden link</u></em>' (length=90)
                  'listing-image-width' => int 400
                  'listing-image-height' => int 400
                  'listing-image-2x' => string '<em><u>hidden link</u></em>' (length=90)
                  'listing-image-2x-width' => int 800
                  'listing-image-2x-height' => int 800
                  'gallery-image' => string '<em><u>hidden link</u></em>' (length=90)
                  'gallery-image-width' => int 667
                  'gallery-image-height' => int 355
                  'gallery-image-2x' => string '<em><u>hidden link</u></em>' (length=91)
                  'gallery-image-2x-width' => int 1334
                  'gallery-image-2x-height' => int 710
          'embed' => string '<a href="<em><u>hidden link</u></em>"><em><u>hidden link</u></em>;' (length=101)

However, on the French translation page I'm getting:

/Users/noxlady/Sites/climate-breakthrough-project/wp-content/themes/radicati/template-home.php:16:boolean false

So obviously although the fields have been translated somehow this information is not making it to the template. I'm a reasonably experienced web dev and my PHP is fairly decent, but WPML has me baffled. Could you please explain where I'm going wrong?

The supporter followed up by recommending that I update my WPML plugins to the latest version, which I did, and that I "Set the repeater fields correctly to translate properly, I can see you have set "highlights" & "_highlights" as translate, which should be copied, more details on this video: hidden link"

-------

I've tried following your instructions but I need some more information. I went into the Homepage Highlights field group and set the Highlights repeater to copy. I also edited the homepage and scrolled down to Multilingual Content Setup section and checked that the "highlights" field is set to copy, rather than translate. However, I'm not seeing a "_highlights" field -- where are you seeing that?

The highlights field is still not showing up on the translated page, and when I

var_dump($post->get_field('highlights'));

in the template on my local (after copying database changes) I'm still getting an empty string on the translated page, though I get a big dump of data on the original (English) page.

Perhaps part of the problem is that my ACF fields on that page are somewhat complicated. Here's a top-down run-through of the structure of the ACF field "Highlights" that appears on that page:

  • The Homepage Highlights field group contains a single repeater field, "Highlights".
  • The Highlights repeater field contains a single clone field, "Highlights", which is built from "All fields from Component: Highlight field group".
  • The Component: Highlight field group contains several fields, including 2 clone fields: "Button" and "Media"
  • The "Button" clone field is built from "All fields from Base: Button field group".
  • The "Media" clone field is built from "All fields from Base: Media Content field group".
  • "Base: Button" and "Base: Media Content" contain only regular fields -- no repeaters or clones.
  • What combination of "translate" and "copy" do I use for each of these fields/field groups in order to have the homepage highlights appear on my translated homepage?
July 16, 2019 at 4:49 am #4216189

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Welcome to WPML support. I'd be assisting you further on this issue.

However, I'm not seeing a "_highlights" field -- where are you seeing that?

- Go to edit the page that contains this fields
- Go to Multilingual content setup
- Click "Show system fields"

You will find the fields now, mark this copy and let me know if this helps.

Thanks

July 16, 2019 at 6:59 pm #4223405

jasonM-25

I clicked on "Show system fields" and toggled "_highlights" to copy rather than translate. So now both "highlights" (which is a repeater field) and "_highlights" (which I think is the system reference to the repeater field?) are now set to "copy" rather than translate.

Then I copied the database to my local. Unfortunately,

	
var_dump($post->get_field('highlights'));

still results in:

/Users/noxlady/Sites/climate-breakthrough-project/wp-content/themes/radicati/template-home.php:12:boolean false

What else should I do to make the translated fields within the "highlights" repeater available to my template??

July 17, 2019 at 3:21 am #4225569

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Can you use the basic loop as explained here and let me know if this helps?
hidden link

If the problem still exists, please provide me the page URL, so I can login and check the issue, I hope the previously provided login is still working, so you can also check the login once and provide the correct one if needed.

Look forward to your reply.

Thanks

July 17, 2019 at 10:29 pm #4233661

jasonM-25

We're using twig templates with the Timber plugin, which is compatible with WPML. With Twig, we don't use the loop at all. Here's Timber's help file on how to output data in a twig template: hidden link. We're successfully outputting the data from the repeater field on the homepage in the original language (English). However, the same code does not output data on the homepage in other languages, although the fields have been translated.

As a troubleshooting step, I'm trying to output the data in my php templates. Once I can output that data there, I'll be able to send it on to my twig templates. However, the homepage repeater field doesn't appear to be available on translated pages. var_dumping that field should not output "false"...

I can confirm that the login and password I set up for you is still functioning on our dev server. I would very much appreciate your advice on how to access the data stored in the translations of our repeater fields.

July 17, 2019 at 10:30 pm #4233663

jasonM-25

The URL of the homepage is hidden link. The repeater field is displaying on the original (English) page but not on the translated pages.

July 18, 2019 at 8:19 am #4235963

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

All the system fields are marked as translate which is wrong, as explained in the video just mark the system fields for repeater fields as "copy" I marked it as copy and noticed there is some content showing except the highlighted fields.

I tried to var_dump and check the issue but since there are no ftp details available I couldn't check it, being so can you please provide me ftp details too.

Enabled the private reply for you.

Thanks

July 18, 2019 at 10:16 pm
July 19, 2019 at 4:36 am #4243823

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Upon further debugging, I noticed that there are two "highlights" fields in the page itself, one is a repeater and another is a clone since the slug is same for both, I think it's creating the conflict, can you rename one of the fields and let me know if this helps?

Look forward to your reply.

Thanks

July 22, 2019 at 8:30 pm #4261177

jasonM-25

I have messed around with renaming fields (and then recreating the data as renaming the field orphans the previous data) fairly extensively on my local and gotten nowhere.

Can we start by debugging a very basic test case and work our way up from there?

I've created a repeater field (cleverly titled "basic_repeater") on the dev server that only appears on the homepage. It contains a text field and an image field. I've filled out 3 "rows" in the repeater in the English version of the page and (fake) translated them into French.

I added that field to my template and it's appearing without trouble on the English version of the page. However, when I switch to the French version of the page, my repeater is not appearing. When I dump the field, I get the expected nested array of awesomeness on the English page, but the French page can only produce a string whose value is the number of rows in my repeater. I cannot iterate through the repeater in French, as this data doesn't seem to be available.

I've added code to both the PHP and Twig templates dumping the data in a few ways so that you can see what I'm talking about. Could you please look at the "basic_repeater" field on my homepage and help me get the data to appear on the French translation? Once we get that working, I'm hopeful that I can apply that technique to the more complex pre-existing repeater fields.

July 23, 2019 at 2:31 am #4262223

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

It seems you missed to mark the system fields "_basic_repeater" copy as a reason the issue was happening, I marked it as copy and it's working, please check it now.

Also, for the images fields, I would request you to mark it as copy and translate it from WPML->Media translation.
https://wpml.org/documentation/getting-started-guide/media-translation/

Look forward to your reply.

Thanks

July 23, 2019 at 5:12 am #4262653

jasonM-25

I'm really glad to see the repeater outputting data on the French translation page 🙂 Unfortunately, I'm noticing that the data being output is the English version (eg "English Text 1") rather than the French version (eg "French Text 1"). Do you have any thoughts as to what's going on with that? How can I make the French version appear instead?

July 23, 2019 at 6:12 am #4262817

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there

I can see it's already showing the french translation so could you please check it once again?

Look forward to your reply.

Thanks

July 29, 2019 at 4:30 pm #4301891

jasonM-25

I'm bumping this topic so it doesn't get closed while I experiment on my local

July 30, 2019 at 10:36 am #4306971

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

The ticket will be open for 2 weeks without any activity, so you can debug it on local and let me know how it goes.

Thanks

The topic ‘[Closed] Followup: Translated fields display on orig lang page, but not translated page’ is closed to new replies.