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

Last updated by jasonM-25 3 months ago.

Assigned support staff: Shekhar Bhandari.

Author Posts
July 2, 2019 at 11:08 pm

jasonM-25

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. For example, when I try:

var_dump(get_post_thumbnail_id());

On the original English homepage I see:

/Users/noxlady/Sites/climate-breakthrough-project/wp-content/themes/radicati/template-home.php:13:string '406' (length=3)

But on the translated (in this case, French) homepage I see:

/Users/noxlady/Sites/climate-breakthrough-project/wp-content/themes/radicati/template-home.php:13:string '' (length=0)

I've got an ACF repeater field for the homepage highlights, 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?

July 3, 2019 at 4:41 am #4131779

Shekhar Bhandari
Supporter

Languages: English (English )

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

Hello there,

Thanks for getting in touch, I can definitely help you out with this.

Here’s what you’ll need to get started:

#1
Update the WPML plugins including ACFML to the latest version. Make sure to create a backup before updating

#2
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

Let me know if this helps.

Thanks

July 15, 2019 at 9:31 pm #4214685

jasonM-25

#1: Ok, I have updated the WPML plugins including ACFML to the latest version.

#2: 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?